error handling in custom request handler

This commit is contained in:
zadam
2019-02-03 11:15:32 +01:00
parent d3ca6b5ae6
commit bad7b84993
10 changed files with 59 additions and 14 deletions

View File

@@ -31,11 +31,18 @@ function register(router) {
log.info(`Handling custom request "${path}" with note ${note.noteId}`);
await scriptService.executeNote(note, {
pathParams: match.slice(1),
req,
res
});
try {
await scriptService.executeNote(note, {
pathParams: match.slice(1),
req,
res
});
}
catch (e) {
log.error(`Custom handler ${note.noteId} failed with ${e.message}`);
res.status(500).send(e.message);
}
}
else if (attr.name === 'customResourceProvider') {
await fileUploadService.downloadNoteFile(attr.noteId, res);