From ff91e49814909c17c7f63a039f2ebe4ea0918f02 Mon Sep 17 00:00:00 2001 From: tokebe <43009413+tokebe@users.noreply.github.com> Date: Wed, 28 Aug 2024 16:00:43 -0400 Subject: [PATCH] handle not implemented error --- src/middlewares/error.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/middlewares/error.ts b/src/middlewares/error.ts index ea0bfff..219dc64 100644 --- a/src/middlewares/error.ts +++ b/src/middlewares/error.ts @@ -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"; @@ -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) {