Skip to content

Commit 230d4a0

Browse files
committed
refactor error handling in RpcErrorKind to use structured messages and improve logging in external bundler send operation
1 parent c3c62e9 commit 230d4a0

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

core/src/error.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ pub enum RpcErrorKind {
2626
NullResp,
2727

2828
/// Rpc server returned an unsupported feature.
29-
#[error("unsupported feature: {0}")]
30-
UnsupportedFeature(String),
29+
#[error("unsupported feature: {message}")]
30+
UnsupportedFeature { message: String },
3131

3232
/// Returned when a local pre-processing step fails. This allows custom
3333
/// errors from local signers or request pre-processors.
34-
#[error("local usage error: {0}")]
35-
InternalError(String),
34+
#[error("local usage error: {message}")]
35+
InternalError { message: String },
3636

3737
/// JSON serialization error.
3838
#[error("serialization error: {message}")]
@@ -327,10 +327,12 @@ fn to_engine_rpc_error_kind(err: &AlloyRpcError<TransportErrorKind>) -> RpcError
327327
data: err.data.as_ref().map(|data| data.to_string()),
328328
}),
329329
AlloyRpcError::NullResp => RpcErrorKind::NullResp,
330-
AlloyRpcError::UnsupportedFeature(feature) => {
331-
RpcErrorKind::UnsupportedFeature(feature.to_string())
332-
}
333-
AlloyRpcError::LocalUsageError(err) => RpcErrorKind::InternalError(err.to_string()),
330+
AlloyRpcError::UnsupportedFeature(feature) => RpcErrorKind::UnsupportedFeature {
331+
message: feature.to_string(),
332+
},
333+
AlloyRpcError::LocalUsageError(err) => RpcErrorKind::InternalError {
334+
message: err.to_string(),
335+
},
334336
AlloyRpcError::SerError(err) => RpcErrorKind::SerError {
335337
message: err.to_string(),
336338
},
@@ -465,4 +467,3 @@ impl From<TwmqError> for EngineError {
465467
}
466468
}
467469
}
468-

executors/src/external_bundler/send.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ where
433433
.build()
434434
.await
435435
.map_err(|e| {
436+
tracing::error!(error = ?e, "Error building user operation");
436437
let mapped_error =
437438
map_build_error(&e, smart_account.address, nonce, needs_init_code);
438439
if is_external_bundler_error_retryable(&mapped_error) {

0 commit comments

Comments
 (0)