fix: do not panic on constructor param errors - #285
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR improves error handling in constructor parameters by replacing panics with proper Result returns. The core change propagates errors from the build() method instead of using unwrap(), preventing runtime panics when client construction fails.
Key Changes:
- Modified
ImpitBuilder::build()to returnResult<Impit, ImpitError>instead ofImpit - Enhanced error messages to include contextual information (URLs, proxy configurations)
- Updated all language bindings (Python, Node.js) to handle the new error-returning API
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| impit/src/impit.rs | Changed build() return type to Result, propagated errors from new_reqwest_client(), added proxy error handling |
| impit/src/errors.rs | Enhanced UrlParsingError to include the URL string, added From<reqwest::Error> implementation |
| impit-python/src/errors.rs | Updated pattern matching for new UrlParsingError(String) variant |
| impit-python/src/client.rs | Added error handling for build() result in synchronous client |
| impit-python/src/async_client.rs | Added error handling for build() result in async client |
| impit-node/src/lib.rs | Added error handling and mapping for build() result in Node.js binding |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
Introduces better error handling for constructor parameter errors.
Closes #280