Skip to content

Commit

Permalink
JVM: propagate schema validation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JesusMcCloud committed Jun 12, 2021
1 parent bb1b569 commit 3cff16f
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ actual class DefaultSchemaValidationService : SchemaValidationService {
val parser = Parser(uriResolver = { resource })
val schema = parser.parse(URI.create("dummy:///"))
val result = schema.validateBasic(json)
result.errors?.let {
if (it.isNotEmpty()) {
//it.forEach { println("${it.error} - ${it.instanceLocation}") }
throw Throwable("Data does not follow schema: ${result.errors}")
result.errors?.let { error ->
if (error.isNotEmpty()) {
throw Throwable("Data does not follow schema: ${result.errors?.map { "${it.error}: ${it.keywordLocation}, ${it.instanceLocation}" }}")
}
}
} catch (t: Throwable) {
verificationResult.error = Error.CBOR_DESERIALIZATION_FAILED
throw t.also { verificationResult.error = Error.CBOR_DESERIALIZATION_FAILED }
}
}

Expand Down

0 comments on commit 3cff16f

Please sign in to comment.