Skip to content

Commit

Permalink
chore: better errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexogamer authored Oct 12, 2023
1 parent 3cef9d4 commit 023e66c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ for (let [ id, theme ] of themes) {
]
);
} catch (err) {
throw `Failed to check "${id}", ${err}`;
throw `Failed to check "${id}": ${err}`;
}
}
9 changes: 7 additions & 2 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,18 @@ export function flatten(object, prefix = '') {
export const themeList = () => readdir('data');
export const resolve = (theme, file) => `data/${theme}/${file}`;
export async function loadTheme(theme) {
let file = await readFile(resolve(theme, 'Preset.toml'));
try {
let file = await readFile(resolve(theme, 'Preset.toml'));
} catch (err) {
throw `Could not load Preset.toml for ${theme} - does it exist?`
}

let data = parse(file.toString());

try {
ensureDefined(data, [ 'slug', 'name', 'creator', 'description', 'variables' ]);
} catch (err) {
throw `Failed to load "${theme}", ${err}`;
throw `Failed to parse "${theme}": ${err}`;
}

let css = resolve(theme, 'Custom.css');
Expand Down

0 comments on commit 023e66c

Please sign in to comment.