From 8ba8fb7bee5d31f8d35eb52318d016662620a549 Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Mon, 22 Apr 2024 11:30:06 +0200 Subject: [PATCH] add error message --- app/build/pmid_to_identifier_rdf4j.sc | 32 ++++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/app/build/pmid_to_identifier_rdf4j.sc b/app/build/pmid_to_identifier_rdf4j.sc index eac44a9..690e807 100644 --- a/app/build/pmid_to_identifier_rdf4j.sc +++ b/app/build/pmid_to_identifier_rdf4j.sc @@ -51,25 +51,41 @@ def main(outfile : String,pc_reference_identifier_files : String*) : Unit = { val format: RDFFormat = RDFFormat.TURTLE try { + val res: GraphQueryResult = QueryResults.parseGraphBackground(is, baseURI, format,null) try { while (res.hasNext()) { - val st: Statement = res.next() - - val objUri = st.getObject().toString() - if (objUri.contains("pubmed.ncbi.nlm.nih.gov") && !objUri.contains("PMC")) { - val sub = st.getSubject().toString().split("/").last.trim - val obj = objUri.split("/").last.trim - fileWriter.write(sub+"\t"+obj+"\n") - } + try { + // println("Hop") + val st: Statement = res.next() + + val objUri = st.getObject().toString() + // println(objUri) + if (objUri.contains("pubmed.ncbi.nlm.nih.gov") && !objUri.contains("PMC")) { + val sub = st.getSubject().toString().split("/").last.trim + val obj = objUri.split("/").last.trim + fileWriter.write(sub+"\t"+obj+"\n") + } + //println("fin Hop") + } catch { + case e: Exception => + // Gérer l'erreur irrécupérable ici + } } + } catch { + case e: Exception => + // Gérer l'erreur irrécupérable ici + System.err.println("1:"+e.getMessage()) + System.exit(-1) } finally { res.close() } } catch { case e: Exception => // Gérer l'erreur irrécupérable ici + System.err.println("1:"+e.getMessage()) + System.exit(-1) } finally { is.close() }