Throw error instances instead of strings and objects - #277
Open
Ragnar-Oock wants to merge 3 commits into
Open
Conversation
BREAKING CHANGE: the exception property is replaced by the native cause property, the dataSet property is still available.
Author
|
CI failed to install Firefox. :/ looks like the firefox download url used by the script is not valid anymore, returned a 404 |
MichaelLeeHobbs
added a commit
to MichaelLeeHobbs/dicomParser
that referenced
this pull request
Jul 23, 2026
) Phase 1 PR 1/5. Replaces legacy littleEndian/bigEndianByteArrayParser + byteStream.js with one DataView-based, bounds-checked ByteStream (endianness as a flag), a numeric tag representation (group*0x10000+element, legacy 'xggggeeee' accepted at boundaries), VR tables including the post-2019 SV/UV/OV long-form VRs (upstream cornerstonejs#280/cornerstonejs#281), and a typed error/warning model (DicomError with code+offset, structured ParseWarning) replacing thrown strings (upstream #46/cornerstonejs#277). Ports legacy-test byteStream_test, littleEndianByteArrayParser_test, bigEndianByteArrayParser_test, byteArrayParser_test to Vitest; adds 64-bit read coverage. Claude-Session: https://claude.ai/code/session_01DSSLWZvjSRByQP3KsghQcJ Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
MichaelLeeHobbs
added a commit
to MichaelLeeHobbs/dicomParser
that referenced
this pull request
Jul 23, 2026
…pixel data Phase 1 PR 3/5. Adds the discriminated-union element model (value | sequence | encapsulated | unknown, upstream cornerstonejs#257/cornerstonejs#278), a frame-stack tokenizer with no recursion and bounded loops (mission-critical standard; maxDepth guard), structural delimiter consumption (cornerstonejs#244/cornerstonejs#143) with delimitation items always treated as zero-length (cornerstonejs#266), CP-246 UN undefined-length sequences, cornerstonejs#114 private implicit policy (never peek private defined-length elements), stopAt with >= semantics (cornerstonejs#104/cornerstonejs#268/#52), typed errors with partial-result salvage (#46/cornerstonejs#203/cornerstonejs#277), and the encapsulated pixel-data scanner (BOT + fragments). Ports readSequenceItemsExplicit/Implicit tests and the sequence/UN halves of readDicomElementExplicit/Implicit tests; adds delimiter-pathology, stopAt, truncation-salvage and depth-bound coverage. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DSSLWZvjSRByQP3KsghQcJ
MichaelLeeHobbs
added a commit
to MichaelLeeHobbs/dicomParser
that referenced
this pull request
Jul 23, 2026
…pixel data (#5) Phase 1 PR 3/5. Adds the discriminated-union element model (value | sequence | encapsulated | unknown, upstream cornerstonejs#257/cornerstonejs#278), a frame-stack tokenizer with no recursion and bounded loops (mission-critical standard; maxDepth guard), structural delimiter consumption (cornerstonejs#244/cornerstonejs#143) with delimitation items always treated as zero-length (cornerstonejs#266), CP-246 UN undefined-length sequences, cornerstonejs#114 private implicit policy (never peek private defined-length elements), stopAt with >= semantics (cornerstonejs#104/cornerstonejs#268/#52), typed errors with partial-result salvage (#46/cornerstonejs#203/cornerstonejs#277), and the encapsulated pixel-data scanner (BOT + fragments). Ports readSequenceItemsExplicit/Implicit tests and the sequence/UN halves of readDicomElementExplicit/Implicit tests; adds delimiter-pathology, stopAt, truncation-salvage and depth-bound coverage. Claude-Session: https://claude.ai/code/session_01DSSLWZvjSRByQP3KsghQcJ Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
MichaelLeeHobbs
added a commit
to MichaelLeeHobbs/dicomParser
that referenced
this pull request
Jul 23, 2026
Adds the '@ubercode/dicom-parser/compat' subpath export: the upstream v1 surface (default-export namespace, parseDicom with vrCallback/inflater/ TransferSyntaxUID/untilTag, DataSet with the full v1 accessor set incl. xggggeeee attributeTag, elements keyed 'xggggeeee' with meta merged in, items/fragments/basicOffsetTable/hadUndefinedLength shapes, string warnings) as a thin wrapper over the core. Meta accessors read little- endian even for BE datasets (legacy per-element parser semantics). Parse failures throw a DicomError (an Error, per #46/cornerstonejs#277) carrying the partial v1 dataSet. Documented divergences: no delimiter leakage (cornerstonejs#244), item lengths exclude delimiters, private undefined-length sequences keep items. Verification oracle #2 (PLAN.md §6): tests/differential.test.ts parses the entire dcmtk.js dicomSamples corpus (199 files, referenced cross-repo, never copied) with the façade AND dicom-parser@1.8.21 (devDep) and compares tag-for-tag: element keysets, VRs, leaf value ranges, fragment counts, and common metadata values. All 199 green locally; suite auto-skips where the corpus is absent (CI). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DSSLWZvjSRByQP3KsghQcJ
MichaelLeeHobbs
added a commit
to MichaelLeeHobbs/dicomParser
that referenced
this pull request
Jul 23, 2026
* feat: DICOM writer — serializer, edit model, round-trip gates Phase 3 (PLAN.md item 13). Adds the write model (tagged WriteValue: bytes/string/numbers/bigints/sequence/fragments; VR-aware encoding with even-length padding, UI NUL-padding, AT/SV/UV support; latin1 + UTF-8 string charsets), an iterative two-pass encoder (normalize+size bottom-up, emit pre-order — no recursion), Part-10 assembly with generated meta group and correct group length, deflated output, and the parse→modify→serialize edit model (modifyDataSet). UN sequences encode implicit content matching CP-246 read semantics; undefined lengths on sequences/items/encapsulation are preserved from parsed input. Write path is little-endian only (BE is read-only, as retired). Round-trip gates: byte-identical re-serialization across the entire testImages corpus (explicit/implicit/encapsulated; deflated files verified parse-equal after recompression; BE asserts read-only), write→parse→write idempotence, modify round-trip, and a dcmdump acceptance suite (runs where DCMTK is installed, skipped in CI). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DSSLWZvjSRByQP3KsghQcJ * feat: v1 compat façade + 199-file legacy differential (Phase 4) Adds the '@ubercode/dicom-parser/compat' subpath export: the upstream v1 surface (default-export namespace, parseDicom with vrCallback/inflater/ TransferSyntaxUID/untilTag, DataSet with the full v1 accessor set incl. xggggeeee attributeTag, elements keyed 'xggggeeee' with meta merged in, items/fragments/basicOffsetTable/hadUndefinedLength shapes, string warnings) as a thin wrapper over the core. Meta accessors read little- endian even for BE datasets (legacy per-element parser semantics). Parse failures throw a DicomError (an Error, per #46/cornerstonejs#277) carrying the partial v1 dataSet. Documented divergences: no delimiter leakage (cornerstonejs#244), item lengths exclude delimiters, private undefined-length sequences keep items. Verification oracle #2 (PLAN.md §6): tests/differential.test.ts parses the entire dcmtk.js dicomSamples corpus (199 files, referenced cross-repo, never copied) with the façade AND dicom-parser@1.8.21 (devDep) and compares tag-for-tag: element keysets, VRs, leaf value ranges, fragment counts, and common metadata values. All 199 green locally; suite auto-skips where the corpus is absent (CI). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DSSLWZvjSRByQP3KsghQcJ --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #46
created
DicomParserErrorto replace the{exception, dataSet}objectreplace thrown string by corresponding native errors (
Error,TypeErrorandRangeError) with appropriate messages.removed the scope from the error messages, the stack trace provide the same information in a more detailed way.
all test passes
fixed linting error on modified lines