Skip to content

Commit

Permalink
Merge pull request #39 from biothings/mcq-501
Browse files Browse the repository at this point in the history
Handle not implemented error
  • Loading branch information
tokebe authored Aug 29, 2024
2 parents d6937d4 + ff91e49 commit cdb1b8e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/middlewares/error.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import swaggerValidation from "./validate";
import { InvalidQueryGraphError } from "@biothings-explorer/query_graph_handler";
import { InvalidQueryGraphError, NotImplementedError } from "@biothings-explorer/query_graph_handler";
import PredicatesLoadingError from "../utils/errors/predicates_error";
import MetaKGLoadingError from "../utils/errors/metakg_error";
import ServerOverloadedError from "../utils/errors/server_overloaded_error";
Expand Down Expand Up @@ -99,6 +99,13 @@ class ErrorHandler {
.set("Retry-After", String((error as ServerOverloadedError).retryAfter))
.json(json);
}

if (error instanceof NotImplementedError || error.name === 'NotImplementedError') {
json.status = "NotImplementedError"
json.description = "The feature you are trying to use is not yet implemented."
return res.status(501).json(json)
}

if (!(error as StatusError).statusCode) (error as StatusError).statusCode = 500;

if ((error as StatusError).statusCode === 301) {
Expand Down

0 comments on commit cdb1b8e

Please sign in to comment.