fix: added error handling for connection issues#56
Open
ronnakamoto wants to merge 3 commits intoLayerTwo-Labs:masterfrom
Open
fix: added error handling for connection issues#56ronnakamoto wants to merge 3 commits intoLayerTwo-Labs:masterfrom
ronnakamoto wants to merge 3 commits intoLayerTwo-Labs:masterfrom
Conversation
Ash-L2L
requested changes
May 19, 2025
| match url::Url::parse(s) { | ||
| Ok(url) => Ok(url), | ||
| Err(e) => { | ||
| let error_msg = e.to_string().to_lowercase(); |
Collaborator
There was a problem hiding this comment.
Can you match on url::ParseError instead? Matching by string value seems brittle and unnecessary
|
|
||
| /// Custom URL parser that adds http:// prefix if missing | ||
| fn parse_url(s: &str) -> Result<url::Url, String> { | ||
| // Check if the URL already has a scheme |
Collaborator
There was a problem hiding this comment.
If the scheme must be http, then perhaps we should only be parsing a url::Host and port (u16), and adding the scheme ourselves
| } | ||
|
|
||
| /// Custom URL parser that adds http:// prefix if missing | ||
| fn parse_url(s: &str) -> Result<url::Url, String> { |
Collaborator
There was a problem hiding this comment.
Can this have a custom error type? Using String seems brittle and limiting
| let rpc_url = self.rpc_url.clone(); | ||
|
|
||
| // Build the client and handle connection errors | ||
| let client = builder.build(self.rpc_url.clone()).map_err(|err| { |
Collaborator
There was a problem hiding this comment.
Is it possible to match on the error here?
| .await | ||
| .map_err(|err| { | ||
| // Check if this is a connection error that happened during the request | ||
| if let Some(client_err) = err.downcast_ref::<jsonrpsee::core::ClientError>() { |
Collaborator
There was a problem hiding this comment.
Downcasting here is very brittle. You probably want to match on the actual errors, so that you can display the correct error message for wrapped errors
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.
This PR addresses issue #11 by improving the error handling for connection issues in the CLI.
Added:
CliErrorto handle connection errors more gracefullyhttp://protocol prefixExample DNS Issue:
Connection Refused:
Connection Timeout: