mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 15:36:16 -04:00
openapi: Convert Promise.catch()
to catch
block
This commit is contained in:
parent
fa8bdb0348
commit
66ce2b50a9
1 changed files with 5 additions and 2 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue