openapi: Convert `Promise.catch()` to `catch` block

pull/5347/head
Richard Hansen 2022-01-02 19:17:20 -05:00
parent fa8bdb0348
commit 66ce2b50a9
1 changed files with 5 additions and 2 deletions

View File

@ -608,7 +608,10 @@ exports.expressPreSession = async (hookName, {app}) => {
} }
// pass to api handler // 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 // convert all errors to http errors
if (createHTTPError.isHttpError(err)) { if (createHTTPError.isHttpError(err)) {
// pass http errors thrown by handler forward // pass http errors thrown by handler forward
@ -623,7 +626,7 @@ exports.expressPreSession = async (hookName, {app}) => {
logger.error(err.stack || err.toString()); logger.error(err.stack || err.toString());
throw new createHTTPError.InternalError('internal error'); throw new createHTTPError.InternalError('internal error');
} }
}); }
// return in common format // return in common format
const response = {code: 0, message: 'ok', data: data || null}; const response = {code: 0, message: 'ok', data: data || null};