Skip to content

Commit 507a4ac

Browse files
committed
Correct detekt errors
1 parent 501d2b8 commit 507a4ac

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

src/main/kotlin/BowtieSampsonSchemaValidatorLauncher.kt

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,7 @@ class BowtieSampsonSchemaValidatorLauncher(
9595

9696
@Suppress("detekt:TooGenericExceptionCaught")
9797
val schema = try {
98-
JsonSchemaLoader.create()
99-
.apply {
100-
currentDialect?.also(this::registerWellKnown)
101-
for ((uri, schema) in command.case.registry) {
102-
if (skipSchema(uri, schema)) {
103-
continue
104-
}
105-
try {
106-
register(schema, uri)
107-
} catch (ex: Exception) {
108-
throw RuntimeException("cannot register schema for URI '$uri'", ex)
109-
}
110-
}
111-
}.fromJsonElement(schemaDefinition, currentDialect)
98+
loadSchema(command, schemaDefinition)
11299
} catch (ex: Exception) {
113100
writer.writeLine(
114101
json.encodeToString(
@@ -126,6 +113,25 @@ class BowtieSampsonSchemaValidatorLauncher(
126113
runCase(command, schema)
127114
}
128115

116+
private fun loadSchema(
117+
command: Command.Run,
118+
schemaDefinition: JsonElement,
119+
): JsonSchema = JsonSchemaLoader.create()
120+
.apply {
121+
currentDialect?.also(this::registerWellKnown)
122+
for ((uri, schema) in command.case.registry) {
123+
if (skipSchema(uri, schema)) {
124+
continue
125+
}
126+
@Suppress("detekt:TooGenericExceptionCaught")
127+
try {
128+
register(schema, uri)
129+
} catch (ex: Exception) {
130+
throw IllegalStateException("cannot register schema for URI '$uri'", ex)
131+
}
132+
}
133+
}.fromJsonElement(schemaDefinition, currentDialect)
134+
129135
private fun skipSchema(uri: String, schema: JsonElement): Boolean {
130136
if (uri.contains("draft4", ignoreCase = true)) {
131137
// skip draft4 schemas

0 commit comments

Comments
 (0)