Skip to content

binding error codes - #25

Merged
tomsideguide merged 6 commits into
mainfrom
feat/binding-error-codes
Aug 5, 2026
Merged

binding error codes#25
tomsideguide merged 6 commits into
mainfrom
feat/binding-error-codes

Conversation

@tomsideguide

@tomsideguide tomsideguide commented Aug 5, 2026

Copy link
Copy Markdown
Member

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

`ConvertError::code()` is the machine-readable discriminant a caller
branches on, where the Display message carries the detail. The Node and
wasm bindings publish it as `error.code`.
- `code` on the rejection names the ConvertError variant, so callers
  branch on it rather than on the message text
- napi fills `code` from the error's status, so the rejection is rebuilt
  in Task::reject, the one place with an Env to build a JS error with
- ConvertErrorCode reaches index.d.ts through a dts header file, which
  survives regeneration
- a js-sys Error with `code` set, thrown as a JsValue, replaces JsError,
  which cannot carry properties
- ConvertErrorCode joins the typescript custom section, minus the crate's
  `io` code: there is no filesystem to fail to read
- the root, node, wasm, and python readmes each document the failure
  model, a worked example, and a table, in the same slot and shape
- python's covers the exception types it already raises
- UnsupportedError, MalformedError, EncryptedError, ResourceLimitError,
  and MissingPartError all subclass ConvertError, so an existing
  `except anydoc.ConvertError` keeps catching every one of them
- the part or stream at fault rides on `part`, the limit crossed on
  `limit`, which is detail the JS bindings cannot carry
- an unreadable file still raises the OSError subclass any other read
  of it would
@tomsideguide
tomsideguide merged commit ace3d1a into main Aug 5, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant