Skip to content
This repository was archived by the owner on Feb 5, 2020. It is now read-only.

Commit 0622409

Browse files
committed
Do not crash on errors.
The SPARQL iterator (source) passes errors to the writer (destination), but ldf-client only handled errors from the source. Hence, if something went wrong with the iterator, the error passed to the writer was not caught.
1 parent 866f7b7 commit 0622409

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

bin/ldf-client

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,24 +66,26 @@ try {
6666
case 'SELECT':
6767
writer = ldf.SparqlResultWriter.instantiate(mimeType, sparqlIterator);
6868
writer.on('data', function (data) { process.stdout.write(data); });
69+
writer.on('error', reportError);
6970
break;
7071
// Write an RDF representation of all results
7172
case 'CONSTRUCT':
7273
case 'DESCRIBE':
7374
config.end = false; // stdout cannot be closed
7475
writer = new N3.Writer(process.stdout, config);
7576
sparqlIterator.on('data', function (triple) { writer.addTriple(triple); })
76-
.on('end', function () { writer.end(); });
77+
.on('end', function () { writer.end(); })
78+
.on('error', reportError);
7779
break;
7880
default:
7981
throw new ldf.SparqlIterator.UnsupportedQueryError(query);
8082
}
8183

82-
// Report an error's stack trace
83-
sparqlIterator.on('error', function (error) {
84+
// Reports an error's stack trace
85+
function reportError(error) {
8486
console.error('ERROR: An error occurred during query execution.\n');
8587
console.error(error.stack);
86-
});
88+
}
8789
}
8890
// Report a synchronous error
8991
catch (error) {

0 commit comments

Comments
 (0)