diff --git a/lib/handlers/get.js b/lib/handlers/get.js index f4aed8eeb..dd46461af 100644 --- a/lib/handlers/get.js +++ b/lib/handlers/get.js @@ -116,10 +116,9 @@ async function handler (req, res, next) { // If it is not in our RDFs we can't even translate, // Sorry, we can't help - if (!possibleRDFType) { - return next(error(406, 'Cannot serve requested type: ' + contentType)) + if (!possibleRDFType || !RDFs.includes(requestedType)) { + return next(error(406, 'Cannot serve requested type: ' + requestedType)) } - try { // Translate from the contentType found to the possibleRDFType desired const data = await translate(stream, baseUri, contentType, possibleRDFType) @@ -127,9 +126,10 @@ async function handler (req, res, next) { res.setHeader('Content-Type', possibleRDFType) res.send(data) return next() - } catch (err) { - debug('error translating: ' + req.originalUrl + ' ' + contentType + ' -> ' + possibleRDFType + ' -- ' + 500 + ' ' + err.message) - return next(error(500, 'Error translating between RDF formats')) + } + catch (err) { + debug('error translating: ' + req.originalUrl + ' ' + contentType + ' -> ' + possibleRDFType + ' -- ' + 406 + ' ' + err.message) + return next(error(406, 'Cannot serve requested type: ' + requestedType)) } }