Under development
These pages are under development.
Issues¶
Every problem the package finds is reported as an issue: an object with a HED error code, a level, and a message. The codes are those of Appendix B of the HED specification, which explains what each one means and when it applies. This page describes the objects and lists the codes the package produces.
The Issue class¶
The string functions (see Validating HED strings) return Issue objects:
const [, errors] = parseStandaloneString('Sensory-event, Blech', schemas)
const issue = errors[0]
console.log(issue instanceof Issue)
console.log(issue.hedCode, issue.internalCode, issue.level)
console.log(issue.parameters)
prints
true
TAG_INVALID invalidTag error
{
tag: 'Blech',
msg: 'Tag extensions must have a parent in the HED schema.'
}
Property |
Meaning |
|---|---|
|
The HED error code from Appendix B, such as |
|
The validator’s own, more specific code, such as |
|
|
|
The full message: level, code, the text with its parameters filled in, and a link to the code. |
|
The values filled into the message, such as the tag, the sidecar key, or the TSV line. |
message is built when it is read, from the template for internalCode and from parameters. Its last part names
the code’s section of Appendix B.
Exceptions: IssueError¶
Most functions return their issues. A few cannot go on after a problem and throw it instead, as an IssueError
whose issue property is the Issue. The main one is schema loading:
try {
await buildSchemasFromVersion('8.4.0, 8.3.0')
} catch (error) {
if (error instanceof IssueError) {
console.log(error.issue.hedCode, error.issue.internalCode)
} else {
throw error
}
}
prints
SCHEMA_LOAD_FAILED multipleVersionsOfSameLibrarySchema
BidsDataset.create catches these and returns them as creation issues, so it does not throw for a bad dataset (see
Validating BIDS datasets).
BIDS issues: BidsHedIssue¶
BidsSidecar.validate, BidsTsvFile.validate, BidsDataset.create, and BidsDataset.validate return
BidsHedIssue objects, the form the BIDS validator uses. Each wraps an Issue (hedIssue) and adds the file:
code is HED_ERROR or HED_WARNING, subCode is the HED code, severity the level, location the file path,
and line the line of a tabular file. The fields are listed in
Issues returned.
BidsHedIssue has static helpers for lists of issues:
splitErrors(issues)- aMapfrom level ('error','warning') to the issues of that level.categorizeByCode(issues)- aMapfrom HED code to the issues with that code.processIssues(issues, checkWarnings, limitErrors)- the errors, plus the warnings ifcheckWarningsis true; iflimitErrorsis true, only the first issue of each code, with a count of all of them added to its message.
const file = new BidsTsvFile(
'events.tsv',
{ path: 'events.tsv' },
'onset\tduration\tHED\n0.5\t0\tRed/Blech\n1.5\t0\tBlech\n',
)
const issues = file.validate(schemas)
console.log(issues.map((issue) => `${issue.severity} ${issue.subCode} line ${issue.line}`))
console.log(BidsHedIssue.processIssues(issues).length, BidsHedIssue.processIssues(issues, true).length)
prints
[ 'error TAG_INVALID line 3', 'warning TAG_EXTENDED line 2' ]
1 2
Error codes¶
The table lists every HED code the package can report, with its level and the internal codes that produce it. It is
generated from src/issues/data.ts, which holds the 114 issue templates. Each linked code opens its section of
Appendix B. INTERNAL_ERROR (a failure inside the validator, or a file it could not read) and VERSION_DEPRECATED
have no section there.
HED code |
Level |
Internal codes |
|---|---|---|
error |
|
|
error |
|
|
error |
|
|
error |
|
|
error |
|
|
warning |
|
|
INTERNAL_ERROR |
error |
|
error |
|
|
error |
|
|
warning |
|
|
error |
|
|
error |
|
|
error |
|
|
error |
|
|
warning |
|
|
error |
|
|
error |
|
|
error |
|
|
warning |
|
|
error |
|
|
error |
|
|
error |
|
|
error |
|
|
error |
|
|
error |
|
|
error |
|
|
error |
|
|
error |
|
|
VERSION_DEPRECATED |
error |
|