Skip to content

Commit

Permalink
Merge pull request #22 from phyloref/handle_jsonld_exception
Browse files Browse the repository at this point in the history
Fixed bug in the Webserver command that prevented RDFParseExceptions being sent to the client. These exceptions will now be caught rather than aborting the HTTP request.
  • Loading branch information
gaurav committed Sep 7, 2018
2 parents 0a98aac + 069c587 commit 5e8399e
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
import org.apache.commons.cli.Options;
import org.eclipse.rdf4j.rio.RDFFormat;
import org.eclipse.rdf4j.rio.RDFHandlerException;
import org.eclipse.rdf4j.rio.RDFParseException;
import org.eclipse.rdf4j.rio.RDFParser;
import org.eclipse.rdf4j.rio.Rio;
import org.json.JSONObject;

import org.openrdf.model.Resource;
import org.openrdf.model.Value;
import org.openrdf.model.impl.ValueFactoryImpl;
Expand Down Expand Up @@ -153,7 +155,7 @@ public Webserver(WebserverCommand cmd, String hostname, int port, CommandLine cm
/**
* Respond to a request for reasoning over a JSON-LD file (/reason).
*/
public JSONObject serveReason(File jsonldFile) throws OWLOntologyCreationException, IOException {
public JSONObject serveReason(File jsonldFile) throws OWLOntologyCreationException, RDFParseException, IOException {
JSONObject response = new JSONObject("{'status': 'ok'}");

// Prepare an ontology to fill with the provided JSON-LD file.
Expand Down Expand Up @@ -439,7 +441,7 @@ public Response serve(IHTTPSession session) {
}

return createResponse(Status.OK, serveReason(jsonldFile));
} catch (OWLOntologyCreationException | IOException ex) {
} catch (OWLOntologyCreationException | RDFParseException | IOException ex) {
response.put("status", "error");
response.put("error", "Exception thrown: " + ex.getMessage());
ex.printStackTrace();
Expand Down

0 comments on commit 5e8399e

Please sign in to comment.