Repository navigation
refactor: Turn send errors into ArgumentError in one place - #212
Merged
Merged
Conversation
- Replace _converting and the two inline try blocks in _dump_json and
_encode_json with one context manager, _guard_argument, which takes what
follows the parameter's name ("as JSON") and a hint for the message.
- Catch ValueError, which covers PydanticSerializationError and
UnicodeDecodeError.
- No behavior changes: the error messages are the same.
Co-Authored-By: Claude Opus 5.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.
What and why
The builder turned serialization and encoding errors into
ArgumentErrorin three places: the_convertinghelper and two inlinetryblocks in_dump_jsonand_encode_json. This replaces them with one context manager,_guard_argument, so the next change to how these errors are reported happens in one place._guard_argumenttakes what follows the parameter's name in the message (such as"as JSON") and an optional hint.ValueError, which coversPydanticSerializationErrorandUnicodeDecodeError.feat/dump-optionsbuilds on this change, so this one should merge first.Testing
make checkpasses: lint, type checks, and 390 tests with the coverage gate.🤖 Generated with Claude Code