Skip to main content
Version: v0.0.3

Class: DicomParseError

Thrown by parseDicom when the input violates one of the four unrecoverable Tier-3 structural rules - or, under { strict: true }, when any Tier-2 warning is escalated through the single emit chokepoint (D-35). Carries byte-offset positional context plus a short source snippet so consumers can log actionable errors.

Message format: [CODE] msg (offset=N), with … in a/b/c appended when contextPath is provided.

Remarks

Snippets may contain PHI when parsing real clinical files - redact at the call site if required by your compliance posture. The library does not redact snippets itself.

Example

import { parseDicom, DicomParseError } from "@cosyte/dicom";
try {
parseDicom(buffer);
} catch (err) {
if (err instanceof DicomParseError && err.code === "NOT_DICOM_PART_10") {
// err.byteOffset, err.snippet, err.contextPath all available
}
}

Extends

  • Error

Constructors

Constructor

new DicomParseError(code, message, byteOffset, snippet, contextPath?): DicomParseError

Internal

Construct a new DicomParseError. All fields except contextPath are required so every thrower populates positional context per TOL-02.

Parameters

code

FatalCode

message

string

byteOffset

number

snippet

string

contextPath?

readonly string[]

Returns

DicomParseError

Overrides

Error.constructor

Properties

byteOffset

readonly byteOffset: number


code

readonly code: FatalCode


contextPath

readonly contextPath: readonly string[] | undefined


snippet

readonly snippet: string