Skip to content

Commit

Permalink
better errors
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Jul 23, 2024
1 parent 11aa43e commit 29bc9af
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ abstract class MappingResolver<T : MappingResolver<T>>(val name: String) {

lateinit var namespaces: Map<Namespace, Boolean>
private set

lateinit var resolved: MemoryMappingTree
private set

Expand Down Expand Up @@ -144,7 +145,7 @@ abstract class MappingResolver<T : MappingResolver<T>>(val name: String) {
}
if (toRemove.isEmpty()) {
//TODO: better logging, determine case
throw IllegalStateException("Circular dependency detected, or missing required ns")
throw IllegalStateException("Circular dependency detected, or missing required ns, remaining: ${resolvedEntries.map { it.id }}")
}

resolvedEntries.removeAll(toRemove)
Expand All @@ -157,13 +158,17 @@ abstract class MappingResolver<T : MappingResolver<T>>(val name: String) {
entry.insertInto.fold(resolved.nsFiltered((entry.provides.map { it.first } + entry.requires).toSet()) as MappingVisitor) { acc, it ->
it(acc)
}
entry.provider.read(
entry.content.content(),
resolved,
visitor,
envType,
entry.mapNs.map { it.key.name to it.value.name }.toMap()
)
try {
entry.provider.read(
entry.content.content(),
resolved,
visitor,
envType,
entry.mapNs.map { it.key.name to it.value.name }.toMap()
)
} catch (e: Throwable) {
throw IllegalStateException("Error reading ${entry.id}", e)
}
}

for (entry in sorted) {
Expand Down

0 comments on commit 29bc9af

Please sign in to comment.