-
Notifications
You must be signed in to change notification settings - Fork 11
Improve error handling and remove panic-prone code #96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Replace unwrap() calls with proper error handling in certificate generation - Convert Ok(..) else patterns to match statements with error context - Standardize error logging with consistent messages - Handle TLS connection errors gracefully instead of panicking - Fix authority parsing to handle invalid values without crashing 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves error handling and removes panic-prone code by replacing unwrap() calls with proper error propagation and logging.
- Certificate generation now returns a Result with propagated errors instead of panicking.
- TLS connection accept and upgrade failures are handled gracefully with appropriate logging.
- The default client now carefully converts host values and parses headers without panicking.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/tls.rs | Updated certificate generation to use error propagation with ? operators. |
| src/lib.rs | Replaced unwrap-based patterns in async connection handling with error logs. |
| src/default_client.rs | Improved error handling in TLS host conversion and header insertion. |
src/lib.rs
Outdated
| generate_cert(host, root_cert.borrow()).map_err(|err| { | ||
| tracing::error!("Failed to generate certificate for host: {}", err); | ||
| }).ok() | ||
| }) | ||
| } else { | ||
| generate_cert(host, root_cert.borrow()) | ||
| .map_err(|err| { | ||
| tracing::error!("Failed to generate certificate for host: {}", err); |
Copilot
AI
Jun 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider including the actual host value in the error message (e.g., 'Failed to generate certificate for host {}: {}') to provide more context for debugging.
| generate_cert(host, root_cert.borrow()).map_err(|err| { | |
| tracing::error!("Failed to generate certificate for host: {}", err); | |
| }).ok() | |
| }) | |
| } else { | |
| generate_cert(host, root_cert.borrow()) | |
| .map_err(|err| { | |
| tracing::error!("Failed to generate certificate for host: {}", err); | |
| generate_cert(host.clone(), root_cert.borrow()).map_err(|err| { | |
| tracing::error!("Failed to generate certificate for host {}: {}", host, err); | |
| }).ok() | |
| }) | |
| } else { | |
| generate_cert(host, root_cert.borrow()) | |
| .map_err(|err| { | |
| tracing::error!("Failed to generate certificate for host {}: {}", host, err); |
Co-authored-by: Copilot <[email protected]>
🤖 Generated with Claude Code