diff --git a/src/node/hooks/express/openapi.js b/src/node/hooks/express/openapi.js index c687b538b..0531854aa 100644 --- a/src/node/hooks/express/openapi.js +++ b/src/node/hooks/express/openapi.js @@ -608,7 +608,10 @@ exports.expressPreSession = async (hookName, {app}) => { } // pass to api handler - const data = await apiHandler.handle(version, funcName, fields, req, res).catch((err) => { + let data; + try { + data = await apiHandler.handle(version, funcName, fields, req, res); + } catch (err) { // convert all errors to http errors if (createHTTPError.isHttpError(err)) { // pass http errors thrown by handler forward @@ -623,7 +626,7 @@ exports.expressPreSession = async (hookName, {app}) => { logger.error(err.stack || err.toString()); throw new createHTTPError.InternalError('internal error'); } - }); + } // return in common format const response = {code: 0, message: 'ok', data: data || null};