120 await next();
121 } catch (error) {
122 if (!(error instanceof APIError)) {
123 error = new APIError({ cause: error });124 }
125 ctx.status = error.statusCode;
126 ctx["api_error"] = error;
If a catch
clause in a try
statement assigns a value to the exception parameter (err
/ error
etc.) accidentally (or on purpose), it is impossible to refer to the error from that point on.
Since there is no alternative way to access this data, assignment of the parameter should be avoided.
try {
// code
} catch (e) {
e = 10;
}
try {
// code
} catch (e) {
// do not reassign error parameter (e)
const foo = 10;
}