This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import { sendJson } from './sendJson.mjs';
|
||||
|
||||
export function sendError(response, error) {
|
||||
const status = error.status || 500;
|
||||
const message = status >= 500 ? 'Internal server error' : error.message;
|
||||
|
||||
if (status >= 500) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
return sendJson(response, { error: message }, status);
|
||||
}
|
||||
Reference in New Issue
Block a user