Better (more private...) error handling
This commit is contained in:
@@ -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',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import Manifest from './Manifest.js';
|
||||
import Sequence from './Sequence.js';
|
||||
import Canvas from './Canvas.js';
|
||||
import Image from './Image.js';
|
||||
import ManifestMetadata from './Metadata.js';
|
||||
|
||||
/**
|
||||
* @namespace Common
|
||||
*/
|
||||
const Common = {};
|
||||
|
||||
const authors = {
|
||||
@@ -103,6 +106,8 @@ Common.getParamsFromFolders = async function() {
|
||||
/**
|
||||
* @param {string} manifestId
|
||||
* @returns {string[]}
|
||||
* @throws `readdir` will thrown an ENOENT error if the images folder doesn't exist.
|
||||
* The manifest route should catch it.
|
||||
*/
|
||||
Common.getImageList = async function (manifestId) {
|
||||
// Regex to exclude images with certain patterns in filename
|
||||
|
||||
Reference in New Issue
Block a user