Improve error handling in server (#812)

* add functions to convert all errors to `ErrorResponse` type

* replace all `{ message: error.toString() }` with `toErrorResponse(error)`

* refactor: all controllers to to use getErrorMessage and add types to the Response

* 404 for nonexistent api routes
This commit is contained in:
Alex Christoffer Rasmussen
2024-04-05 23:06:40 +02:00
committed by GitHub
parent d432f1e3ff
commit 8a1474e8d6
15 changed files with 120 additions and 58 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ export { deepmerge } from './src/externals/deepmerge.js';
export { deleteAtIndex, insertAtIndex, reorderArray, sortArrayByProperty } from './src/array-utils/arrayUtils.js';
// generic utilities
export { unpackError } from './src/generic/generic.js';
export { getErrorMessage } from './src/generic/generic.js';
export { obfuscate, unobfuscate } from './src/generic/generic.js';
export { isNumeric } from './src/types/types.js';
+1 -1
View File
@@ -1,4 +1,4 @@
export function unpackError(error: unknown): string {
export function getErrorMessage(error: unknown): string {
if (error instanceof Error) {
return error.message;
}