@@ -95,20 +95,7 @@ class BowtieSampsonSchemaValidatorLauncher(
95
95
96
96
@Suppress(" detekt:TooGenericExceptionCaught" )
97
97
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)
112
99
} catch (ex: Exception ) {
113
100
writer.writeLine(
114
101
json.encodeToString(
@@ -126,6 +113,25 @@ class BowtieSampsonSchemaValidatorLauncher(
126
113
runCase(command, schema)
127
114
}
128
115
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
+
129
135
private fun skipSchema (uri : String , schema : JsonElement ): Boolean {
130
136
if (uri.contains(" draft4" , ignoreCase = true )) {
131
137
// skip draft4 schemas
0 commit comments