mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
feat(route): allow for routes to handle their own response
This commit is contained in:
parent
ca6277f6e9
commit
41906abaf9
@ -158,6 +158,11 @@ function handleException(e: unknown | Error, method: HttpMethod, path: string, r
|
||||
|
||||
log.error(`${method} ${path} threw exception: '${errMessage}', stack: ${errStack}`);
|
||||
|
||||
// Skip sending response if it's already been handled by the route handler
|
||||
if ((res as unknown as { triliumResponseHandled?: boolean }).triliumResponseHandled || res.headersSent) {
|
||||
return;
|
||||
}
|
||||
|
||||
const resStatusCode = (e instanceof ValidationError || e instanceof NotFoundError) ? e.statusCode : 500;
|
||||
|
||||
res.status(resStatusCode).json({
|
||||
|
Loading…
x
Reference in New Issue
Block a user