diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2024-01-15 06:12:33 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-15 11:12:33 +0000 |
commit | 48f1d012ad5045319d4e492dfbefa39da92817b2 (patch) | |
tree | 51b5b53a7b1192f04a8292c3a9aa0f5063c64b46 /dev/dictionary-validate.js | |
parent | 9cfa20cbd2289d82a5abf05a2e5ea8af5016222c (diff) |
Add toError utility function (#523)
* Add asError utility function
* Rename to toError
Diffstat (limited to 'dev/dictionary-validate.js')
-rw-r--r-- | dev/dictionary-validate.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/dev/dictionary-validate.js b/dev/dictionary-validate.js index 51edcc50..3727310e 100644 --- a/dev/dictionary-validate.js +++ b/dev/dictionary-validate.js @@ -23,6 +23,7 @@ import {performance} from 'perf_hooks'; import {fileURLToPath} from 'url'; import {parseJson} from './json.js'; import {createJsonSchema} from './schema-validate.js'; +import {toError} from './to-error.js'; const dirname = path.dirname(fileURLToPath(import.meta.url)); @@ -47,7 +48,7 @@ async function validateDictionaryBanks(mode, zip, fileNameFormat, schema) { try { jsonSchema = createJsonSchema(mode, schema); } catch (e) { - const e2 = e instanceof Error ? e : new Error(`${e}`); + const e2 = toError(e); e2.message += `\n(in file ${fileNameFormat})}`; throw e2; } @@ -62,7 +63,7 @@ async function validateDictionaryBanks(mode, zip, fileNameFormat, schema) { try { jsonSchema.validate(data); } catch (e) { - const e2 = e instanceof Error ? e : new Error(`${e}`); + const e2 = toError(e); e2.message += `\n(in file ${fileName})}`; throw e2; } @@ -92,7 +93,7 @@ export async function validateDictionary(mode, archive, schemas) { const jsonSchema = createJsonSchema(mode, schemas.index); jsonSchema.validate(index); } catch (e) { - const e2 = e instanceof Error ? e : new Error(`${e}`); + const e2 = toError(e); e2.message += `\n(in file ${indexFileName})}`; throw e2; } |