monarch-initiative / biolink-api

API for linked biological knowledge
https://api.monarchinitiative.org/api/
BSD 3-Clause "New" or "Revised" License
64 stars 25 forks source link

Improve error handling #256

Closed deepakunni3 closed 5 years ago

deepakunni3 commented 5 years ago

This PR adds the ability to handle errors and exceptions.

This ensures that a user never has to see an error message like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request.  Either the server is overloaded or there is an error in the application.</p>

Instead, the response will always be a JSON, even in the case of errors on the server:

{
    "error": {
        "message": "SciGraph dynamic/cliqueLeader yields no result for PMID:28847661",
        "code": 400,
        "debug": {}
    }
}

This is an initial take at better handling and propagating the underlying problem to the user.

Even if Ontobio encounters an exception, there is now a default exception handler in BioLink API that will handle it.

kltm commented 5 years ago

@deepakunni3 Mind if I ask you about this off thread? I may not have enough context.

kshefchek commented 5 years ago

+1