Skip to content

Commit

Permalink
Improve error message for invalid version/no schema
Browse files Browse the repository at this point in the history
  • Loading branch information
will-moore committed Oct 24, 2022
1 parent 1c40a6a commit 58094dd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ export async function getSchema(version, schemaName = "image") {
if (!schemas[cacheKey]) {
const schema_url = getSchemaUrl(schemaName, version);
console.log("Loading schema... " + schema_url);
const schema = await getJson(schema_url);
// delete to avoid invalid: $schema: "https://json-schema.org/draft/2020-12/schema" not found
delete schema["$schema"];
schemas[cacheKey] = schema;
try {
const schema = await getJson(schema_url);
// delete to avoid invalid: $schema: "https://json-schema.org/draft/2020-12/schema" not found
delete schema["$schema"];
schemas[cacheKey] = schema;
} catch (error) {
throw new Error(`No schema at ${schema_url}. Version ${version} may be invalid.`);
}
}
return schemas[cacheKey];
}
Expand Down

0 comments on commit 58094dd

Please sign in to comment.