Skip to content
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

fix: use error(transparent) for wrapped errors when possible #1449

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion client/http-client/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
// DEALINGS IN THE SOFTWARE.

use crate::types::error::{ErrorCode, ErrorObject};

use crate::HttpClientBuilder;
use jsonrpsee_core::client::{BatchResponse, ClientT, IdKind};
use jsonrpsee_core::params::BatchRequestBuilder;
Expand Down
2 changes: 1 addition & 1 deletion client/http-client/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ pub enum Error {
Url(String),

/// Error during the HTTP request, including networking errors and HTTP protocol errors.
#[error("{0}")]
#[error(transparent)]
Http(#[from] HttpError),

/// Server returned a non-success status code.
Expand Down
2 changes: 1 addition & 1 deletion client/transport/src/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub enum Error {
#[error("JS Error: {0:?}")]
Js(String),
/// WebSocket error
#[error("{0}")]
#[error(transparent)]
WebSocket(WebSocketError),
/// Operation not supported
#[error("Operation not supported")]
Expand Down
6 changes: 3 additions & 3 deletions core/src/client/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub enum Error {
#[error("Invalid subscription ID")]
InvalidSubscriptionId,
/// Invalid request ID.
#[error("{0}")]
#[error(transparent)]
InvalidRequestId(#[from] InvalidRequestId),
/// Request timeout
#[error("Request timeout")]
Expand All @@ -61,9 +61,9 @@ pub enum Error {
#[error("Not implemented")]
HttpNotImplemented,
/// Empty batch request.
#[error("{0}")]
#[error(transparent)]
EmptyBatchRequest(#[from] EmptyBatchRequest),
/// The error returned when registering a method or subscription failed.
#[error("{0}")]
#[error(transparent)]
RegisterMethod(#[from] RegisterMethodError),
}
2 changes: 1 addition & 1 deletion core/src/http_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pub enum HttpError {
#[error("Malformed request")]
Malformed,
/// Represents error that can happen when dealing with HTTP streams.
#[error("{0}")]
#[error(transparent)]
Stream(#[from] BoxError),
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/server/rpc_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ pub type RawRpcResponse = (String, mpsc::Receiver<String>);
#[derive(thiserror::Error, Debug)]
pub enum MethodsError {
/// Failed to parse the call as valid JSON-RPC.
#[error("{0}")]
#[error(transparent)]
Parse(#[from] serde_json::Error),
/// Specific JSON-RPC error.
#[error("{0}")]
#[error(transparent)]
JsonRpc(#[from] ErrorObjectOwned),
#[error("Invalid subscription ID: `{0}`")]
/// Invalid subscription ID.
Expand Down
4 changes: 2 additions & 2 deletions server/src/middleware/http/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ pub struct Authority {
#[derive(Debug, thiserror::Error)]
pub enum AuthorityError {
/// Invalid URI.
#[error("{0}")]
#[error(transparent)]
InvalidUri(InvalidUri),
/// Invalid port.
#[error("{0}")]
#[error("Invalid port: {0}")]
InvalidPort(String),
/// The host was not found.
#[error("The host was not found")]
Expand Down
Loading