Skip to content

Commit 23cf8be

Browse files
committed
chore(generator-common): wrap mapping tree creation exceptions
1 parent eaa07a6 commit 23cf8be

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* This file is part of takenaka, licensed under the Apache License, Version 2.0 (the "License").
3+
*
4+
* Copyright (c) 2023-2024 Matous Kucera
5+
*
6+
* You may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package me.kcra.takenaka.generator.common.provider
19+
20+
/**
21+
* A generic resolve-time exception wrapper.
22+
*
23+
* @author Matouš Kučera
24+
*/
25+
open class ResolveException : RuntimeException {
26+
constructor(message: String, cause: Throwable) : super(message, cause)
27+
constructor(message: String) : super(message)
28+
}

generator/common/src/main/kotlin/me/kcra/takenaka/generator/common/provider/impl/ResolvingMappingProvider.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import me.kcra.takenaka.core.versionManifest
3232
import me.kcra.takenaka.core.versionManifestOf
3333
import me.kcra.takenaka.generator.common.provider.MappingProvider
3434
import io.github.oshai.kotlinlogging.KotlinLogging
35+
import me.kcra.takenaka.generator.common.provider.ResolveException
3536
import net.fabricmc.mappingio.format.Tiny2Reader
3637
import net.fabricmc.mappingio.format.Tiny2Writer
3738
import net.fabricmc.mappingio.tree.MemoryMappingTree
@@ -144,12 +145,17 @@ class ResolvingMappingProvider @Deprecated(
144145
}
145146
}
146147

147-
val tree = buildMappingTree {
148-
contributor(contributors)
148+
val treeResult = runCatching {
149+
buildMappingTree {
150+
contributor(contributors)
149151

150-
interceptors += mappingConfig.interceptors
152+
interceptors += mappingConfig.interceptors
153+
}
151154
}
152155

156+
val tree = treeResult.getOrElse { exc ->
157+
throw ResolveException("Failed to create mapping tree for version ${workspace.version}", exc)
158+
}
153159
if (analyzer != null) {
154160
val time = measureTimeMillis { analyzer.accept(tree) }
155161
logger.info { "analyzed ${workspace.version.id} mappings in ${time}ms" }

0 commit comments

Comments
 (0)