Skip to content

Commit 038e8bd

Browse files
authored
Merge pull request #270 from yarikoptic/enh-crash
Throw an error, do not just log an error, if provided schema is not legit
2 parents a01f420 + 7d105ff commit 038e8bd

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
### Changed
2+
3+
- Throw an error if specified schema (e.g. via `--schema` or `BIDS_SCHEMA` env
4+
var) could not be loaded.

src/setup/loadSchema.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { setCustomMetadataFormats } from '../validators/json.ts'
66
/**
77
* Load the schema from the specification
88
*
9-
* version is ignored when the network cannot be accessed
109
*/
1110
export async function loadSchema(version?: string): Promise<Schema> {
1211
let schemaUrl = version
@@ -31,10 +30,10 @@ export async function loadSchema(version?: string): Promise<Schema> {
3130
objectPathHandler,
3231
) as Schema
3332
} catch (error) {
34-
// No network access or other errors
33+
// If a custom schema URL was explicitly provided, fail rather than falling back
3534
console.error(error)
36-
console.error(
37-
`Warning, could not load schema from ${schemaUrl}, falling back to internal version`,
35+
throw new Error(
36+
`Failed to load schema from ${schemaUrl}: ${error instanceof Error ? error.message : String(error)}`,
3837
)
3938
}
4039
}

0 commit comments

Comments
 (0)