diff --git a/apps/registry/pages/api/[payload].js b/apps/registry/pages/api/[payload].js index d014a58..1f45136 100644 --- a/apps/registry/pages/api/[payload].js +++ b/apps/registry/pages/api/[payload].js @@ -54,7 +54,7 @@ export default async function handler(req, res) { const formatter = FORMATTERS[fileType]; if (!formatter) { - return res.status(200).send(failMessage('not supported formatted')); + return res.status(200).send(failMessage('not supported formatter')); } if ( @@ -120,7 +120,7 @@ export default async function handler(req, res) { }); } catch (e) { // If gist url is invalid, flush the gistid in cache - return res.status(200).send(failMessage('Cannot fetch gist, no idea why')); + return res.status(400).send(failMessage('Cannot fetch gist, no idea why')); } let realTheme = @@ -132,7 +132,7 @@ export default async function handler(req, res) { const validation = v.validate(selectedResume, schema); if (!validation.valid) { - return res.status(200).send( + return res.status(400).send( failMessage('Validation failed') + ` @@ -172,9 +172,19 @@ ${JSON.stringify(validation.errors, null, 2)} try { formatted = await formatter.format(selectedResume, options); } catch (e) { - console.log(e); + // @todo - do this better + if (e.message === 'theme-missing') { + return res + .status(400) + .send( + failMessage( + 'This theme is currently unsupported. Please visit this Github issue to request it https://github.com/jsonresume/jsonresume.org/issues/36 (unfortunately we have recently (11/2023) disabled a bunch of legacy themes due to critical flaws in them, please request if you would like them back.)' + ) + ); + } + return res - .status(200) + .status(400) .send( failMessage( 'Cannot format resume, no idea why #likely-a-validation-error' diff --git a/apps/registry/pages/api/formatters/template.js b/apps/registry/pages/api/formatters/template.js index 074b202..0afcab6 100644 --- a/apps/registry/pages/api/formatters/template.js +++ b/apps/registry/pages/api/formatters/template.js @@ -48,6 +48,11 @@ const getTheme = (theme) => { const format = async function (resume, options) { const theme = options.theme ?? 'elegant'; const themeRenderer = getTheme(theme); + + if (!themeRenderer) { + throw new Error('theme-missing'); + } + const resumeHTML = themeRenderer.render(resume); return {