Skip to content

Commit

Permalink
handle not implemented error
Browse files Browse the repository at this point in the history
  • Loading branch information
tokebe committed Aug 28, 2024
1 parent d6937d4 commit ff91e49
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 ff91e49

Please sign in to comment.