diff --git a/changelog.d/20250918_173356_yarikoptic_enh_crash.md b/changelog.d/20250918_173356_yarikoptic_enh_crash.md new file mode 100644 index 00000000..8c3e18b2 --- /dev/null +++ b/changelog.d/20250918_173356_yarikoptic_enh_crash.md @@ -0,0 +1,4 @@ +### Changed + +- Throw an error if specified schema (e.g. via `--schema` or `BIDS_SCHEMA` env + var) could not be loaded. diff --git a/src/setup/loadSchema.ts b/src/setup/loadSchema.ts index d8b45f56..8c6f494e 100644 --- a/src/setup/loadSchema.ts +++ b/src/setup/loadSchema.ts @@ -6,7 +6,6 @@ import { setCustomMetadataFormats } from '../validators/json.ts' /** * Load the schema from the specification * - * version is ignored when the network cannot be accessed */ export async function loadSchema(version?: string): Promise { let schemaUrl = version @@ -31,10 +30,10 @@ export async function loadSchema(version?: string): Promise { objectPathHandler, ) as Schema } catch (error) { - // No network access or other errors + // If a custom schema URL was explicitly provided, fail rather than falling back console.error(error) - console.error( - `Warning, could not load schema from ${schemaUrl}, falling back to internal version`, + throw new Error( + `Failed to load schema from ${schemaUrl}: ${error instanceof Error ? error.message : String(error)}`, ) } }