Skip to content

Commit d838fef

Browse files
committed
throw new error instead of console.error
1 parent 370f785 commit d838fef

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/knowledge-collection-tools.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ export function generateMissingIdsForBlankNodes(nquadsArray) {
363363
}
364364
const unsupportedNquads = [];
365365
const updatedNquads = parser.parse(nquadsArray.join("")).map((quad) => {
366-
// Check if BlankNodes are parsed as named graphs
366+
// Check if BlankNodes are parsed as graphs
367367
if (quad.graph.termType === "BlankNode") {
368368
unsupportedNquads.push(writer.quadToString(quad.object, quad.predicate, quad.object, quad.graph));
369369
}
@@ -379,9 +379,9 @@ export function generateMissingIdsForBlankNodes(nquadsArray) {
379379
});
380380

381381
if (unsupportedNquads.length > 0) {
382-
console.error(`
382+
throw new Error(`
383383
------------------------------------------------------------------------------------------------
384-
Error: Unsupported JSON-LD input detected
384+
Unsupported JSON-LD input detected
385385
386386
After parsing the JSON-LD input, the parser detected creation of new named graphs.
387387
The DKG does not support custom named graphs.
@@ -390,9 +390,10 @@ Problematic Quads:
390390
${unsupportedNquads.map((q, i) => ` ${i + 1}. ${q}`).join("\n")}
391391
392392
Full Parsed N-Quads Array:
393-
`, nquadsArray, '\n');
394-
395-
throw new Error("Parsing failed due to presence of unnamed (blank node) graphs. Please ensure all graphs in the input JSON-LD have proper named IRIs.");
393+
${nquadsArray.join('\n')}
394+
Parsing failed due to presence of unnamed (blank node) graphs. Please ensure all graphs in the input JSON-LD have proper named IRIs.
395+
`
396+
);
396397
}
397398

398399
return writer.quadsToString(updatedNquads).trimEnd().split("\n");

0 commit comments

Comments
 (0)