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

[rpc] Simplify error response from execute_transaction_block of transaction_execution_api #12989

Merged
merged 9 commits into from
Aug 14, 2023
Prev Previous commit
Next Next commit
assert on no nonretryableerrors and test
  • Loading branch information
wlmyng committed Aug 10, 2023
commit 62a7fc9391e6c230f817a5274ca4f27cf91537d0
28 changes: 15 additions & 13 deletions crates/sui-json-rpc/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,19 @@ impl From<Error> for RpcError {
})
.collect();

let (error_code, error_msg) = if new_errors.is_empty() {
(
TRANSIENT_ERROR_CODE,
"Transaction execution failed due to transient errors, please try again.".to_string(),
)
} else {
let error_list = new_errors.join(", ");
(
TRANSACTION_EXECUTION_CLIENT_ERROR_CODE,
format!("Transaction execution failed due to issues with transaction inputs, please review the errors and try again: {}.", error_list),
)
};
assert!(
!new_errors.is_empty(),
"NonRecoverableTransactionError should have at least one non-retryable error"
);

let error_object = ErrorObject::owned(error_code, error_msg, None::<()>);
let error_list = new_errors.join(", ");
let error_msg = format!("Transaction execution failed due to issues with transaction inputs, please review the errors and try again: {}.", error_list);

let error_object = ErrorObject::owned(
TRANSACTION_EXECUTION_CLIENT_ERROR_CODE,
error_msg,
None::<()>,
);
RpcError::Call(CallError::Custom(error_object))
}
QuorumDriverError::QuorumDriverInternalError(_) => {
Expand Down Expand Up @@ -386,6 +385,9 @@ mod tests {
}

#[test]
#[should_panic(
expected = "NonRecoverableTransactionError should have at least one non-retryable error"
)]
fn test_non_recoverable_transaction_error_with_transient_errors() {
let quorum_driver_error = QuorumDriverError::NonRecoverableTransactionError {
errors: vec![
Expand Down