openapi: Convert `Promise.catch()` to `catch` block
parent
fa8bdb0348
commit
66ce2b50a9
|
@ -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};
|
||||||
|
|
Loading…
Reference in New Issue