fix unhandled exception (#473)

* handle error and return 400

* Update accounts.js

* Update accounts.js

* new test passing
This commit is contained in:
Sam Machin
2025-06-26 18:09:42 +01:00
committed by GitHub
parent 1532a4ab9c
commit 781179bf0e
2 changed files with 19 additions and 1 deletions

View File

@@ -286,7 +286,11 @@ const hasAccountPermissions = async(req, res, next) => {
message: 'insufficient privileges'
});
} catch (error) {
throw error;
// return 400 on errors
res.status(400).json({
status: 'fail',
message: error.message
});
}
};