mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
fix edge case where res.respond would not work, misc comments
This commit is contained in:
@@ -74,5 +74,7 @@ export default function errorHandler (err, req, res, next) { // eslint-disable-l
|
||||
|
||||
if (responseErr.errors) jsonRes.errors = responseErr.errors;
|
||||
|
||||
return res.respond(responseErr.httpCode, jsonRes);
|
||||
// In some occasions like when invalid JSON is supplied `res.respond` might be not yet avalaible,
|
||||
// in this case we use the standard res.status(...).json(...)
|
||||
return res.respond ? res.respond(responseErr.httpCode, jsonRes) : res.status(responseErr.httpCode).json(jsonRes);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user