Better (more private...) error handling

This commit is contained in:
2026-03-13 12:01:13 +01:00
parent 69fc7235c6
commit 4b9b5b737d
2 changed files with 22 additions and 5 deletions

View File

@@ -18,7 +18,7 @@ router.get('/iiif/:manifestid/manifest', async function(req, res) {
res.status(500).json({
status: 500,
message: 'There was an error processing this request',
details: error
code: error.code ?? 'not available',
});
}
res.json(manifest);
@@ -31,7 +31,11 @@ router.get('/iiif/:manifestid/canvas/:name', async function(req, res) {
try {
canvas = await generateCanvas(req.params.manifestid, req.params.name)
} catch(error) {
res.status(500).json({status: 500, message: 'There was an error processing this request: ' + error});
res.status(500).json({
status: 500,
message: 'There was an error processing this request',
code: error.code ?? 'not available',
});
return;
}
res.json(canvas);
@@ -44,7 +48,11 @@ router.get('/iiif/:manifestid/sequence/:name', async function(req, res) {
try {
sequence = await generateSequence(req.params.manifestid, req.params.name)
} catch(error) {
res.status(500).json({status: 500, message: 'There was an error processing this request'});
res.status(500).json({
status: 500,
message: 'There was an error processing this request',
code: error.code ?? 'not available',
});
}
res.json(sequence);
});
@@ -55,7 +63,11 @@ router.get('/params', async function(req, res) {
try {
res.json(await exposeParams());
} catch(error) {
res.status(500).json({status: 500, message: 'There was an error processing this request'});
res.status(500).json({
status: 500,
message: 'There was an error processing this request',
code: error.code ?? 'not available',
});
}
});