Skip to content

Commit f53dc84

Browse files
committed
Throw and error, do not just log an error, if provided schema is not readable
I think current behavior violates the principle of the least surprise: I ran validation while providing custom schema source, it executed with many warnings and errors reported to the screen. It is only after scrolling far up, I saw that actually my specification was wrong and operation resorted to built-in schema.
1 parent a01f420 commit f53dc84

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/setup/loadSchema.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ export async function loadSchema(version?: string): Promise<Schema> {
3131
objectPathHandler,
3232
) as Schema
3333
} catch (error) {
34-
// No network access or other errors
34+
// If a custom schema URL was explicitly provided, fail rather than falling back
3535
console.error(error)
36-
console.error(
37-
`Warning, could not load schema from ${schemaUrl}, falling back to internal version`,
36+
throw new Error(
37+
`Failed to load schema from ${schemaUrl}: ${error instanceof Error ? error.message : String(error)}`,
3838
)
3939
}
4040
}

0 commit comments

Comments
 (0)