Commit 0ce345d5 authored by Jonas Waeber's avatar Jonas Waeber

Add general exception handler if something happens. Make this a fatal exception.

parent 5b8d057e
Pipeline #21828 passed with stage
in 2 minutes
......@@ -42,7 +42,8 @@ class ResourceBuilder(
private var digitalObject: DigitalObject? = null
private var recordId = ""
private var recordTypeValue = ""
val errorMessages = mutableListOf<String>()
val errorMessages: MutableList<String> = mutableListOf()
var isFatal = false
fun extractRecordId(): ResourceBuilder {
if (source.containsKey(config.uri)) {
......@@ -98,7 +99,10 @@ class ResourceBuilder(
try {
recordFieldMapper.apply(source, record!!)
} catch (ex: InvalidInputException) {
errorMessages.add(ex.localizedMessage + " Could not apply ${recordFieldMapper::class.java} for record.")
errorMessages.add(ex.localizedMessage + " Could not apply ${recordFieldMapper::class.simpleName} for record.")
} catch (ex: Exception) {
errorMessages.add(ex.localizedMessage + " Could not apply ${recordFieldMapper::class.simpleName} for record.")
isFatal = true
}
}
return this
......@@ -112,7 +116,10 @@ class ResourceBuilder(
try {
it.apply(source, physicalObject)
} catch (ex: InvalidInputException) {
errorMessages.add(ex.localizedMessage + " Could not apply ${it::class.java} for physical instantiation.")
errorMessages.add(ex.localizedMessage + " Could not apply ${it::class.simpleName} for physical instantiation.")
} catch (ex: Exception) {
errorMessages.add(ex.localizedMessage + " Could not apply ${it::class.simpleName} for physical instantiation.")
isFatal = true
}
}
record?.addInstantiation(physicalObject)
......@@ -132,7 +139,10 @@ class ResourceBuilder(
try {
it.apply(source, digitalObject)
} catch (ex: InvalidInputException) {
errorMessages.add(ex.localizedMessage + " Could not apply ${it::class.java} for digital instantiation.")
errorMessages.add(ex.localizedMessage + " Could not apply ${it::class.simpleName} for digital instantiation.")
} catch (ex: Exception) {
errorMessages.add(ex.localizedMessage + " Could not apply ${it::class.simpleName} for digital instantiation.")
isFatal = true
}
}
digitalObject.addRecord(record!!)
......
......@@ -239,7 +239,7 @@ class TestAgentMapper {
assertThat(sort(ntriples.second.split("\n")))
.isEqualTo(readOutputFile("output-1"))
},
{ assertThat(ntriples.third[0]).isEqualTo("Encountered an unexpected empty value for mapping name -> contributorPerson.name. Could not apply class ch.memobase.mapping.mappers.AgentFieldMapper for record.") }
{ assertThat(ntriples.third[0]).isEqualTo("Encountered an unexpected empty value for mapping name -> contributorPerson.name. Could not apply AgentFieldMapper for record.") }
)
}
......
......@@ -5,15 +5,6 @@
@prefix ebucore: <http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
_:b0 a rico:CreationRelation ;
rico:creationRelationHasSource <https://memobase.ch/record/rs1-1> ;
rico:creationRelationHasTarget [ a rico:Person ;
rico:agentIsTargetOfCreationRelation
_:b0 ;
rico:name "Hans Zimmer"
] ;
rico:type "creator" .
<https://memobase.ch/record/rs1-1>
a rico:Record ;
rdau:P60451 <https://memobase.ch/institution/mrv> ;
......@@ -28,3 +19,12 @@ _:b0 a rico:CreationRelation ;
rico:recordResourceOrInstantiationIsSourceOfCreationRelation
_:b0 ;
rico:type "Foto" .
_:b0 a rico:CreationRelation ;
rico:creationRelationHasSource <https://memobase.ch/record/rs1-1> ;
rico:creationRelationHasTarget [ a rico:Person ;
rico:agentIsTargetOfCreationRelation
_:b0 ;
rico:name "Hans Zimmer"
] ;
rico:type "creator" .
......@@ -20,14 +20,13 @@
_:b0 , _:b1 , _:b2 ;
rico:type "Foto" .
_:b2 a rico:CreationRelation ;
_:b0 a rico:CreationRelation ;
rico:creationRelationHasSource <https://memobase.ch/record/rs1-1> ;
rico:creationRelationHasTarget [ a rico:Person ;
rico:agentIsTargetOfCreationRelation
_:b2 ;
rico:name "First Person"
_:b0 ;
rico:name "Second Person"
] ;
rico:name "Relation 1" ;
rico:type "creator" .
_:b1 a rico:CreationRelation ;
......@@ -35,16 +34,17 @@ _:b1 a rico:CreationRelation ;
rico:creationRelationHasTarget [ a rico:Person ;
rico:agentIsTargetOfCreationRelation
_:b1 ;
rico:name "Third Person"
rico:name "First Person"
] ;
rico:name "Relation 3" ;
rico:name "Relation 1" ;
rico:type "creator" .
_:b0 a rico:CreationRelation ;
_:b2 a rico:CreationRelation ;
rico:creationRelationHasSource <https://memobase.ch/record/rs1-1> ;
rico:creationRelationHasTarget [ a rico:Person ;
rico:agentIsTargetOfCreationRelation
_:b0 ;
rico:name "Second Person"
_:b2 ;
rico:name "Third Person"
] ;
rico:name "Relation 3" ;
rico:type "creator" .
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment