From 6c2b30e7fad64038f0ba03699f01277b8b5fbf52 Mon Sep 17 00:00:00 2001 From: Ajax Davis Date: Wed, 29 Nov 2023 20:31:41 +1100 Subject: [PATCH] feat: add a link to a github issue when themes are missing --- apps/registry/pages/api/[payload].js | 14 ++++++++++++-- apps/registry/pages/api/formatters/template.js | 5 +++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/apps/registry/pages/api/[payload].js b/apps/registry/pages/api/[payload].js index d014a58..3e5897c 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 ( @@ -172,7 +172,17 @@ ${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(200) + .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) .send( 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 {