binding error codes - #25
Merged
Merged
Conversation
`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
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.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.