Skip to content

Commit

Permalink
feat: add a link to a github issue when themes are missing
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasdavis committed Nov 29, 2023
1 parent 257e367 commit 6c2b30e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
14 changes: 12 additions & 2 deletions apps/registry/pages/api/[payload].js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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(
Expand Down
5 changes: 5 additions & 0 deletions apps/registry/pages/api/formatters/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 6c2b30e

Please sign in to comment.