Skip to content

Commit 6f946fe

Browse files
author
Yasir
authored
Merge pull request #72 from bitfinity-network/add-data-for-error
EPROD-581 chore: add extra data to error
2 parents 0664f16 + 322a3ec commit 6f946fe

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/did/src/error.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ pub enum EvmError {
5959

6060
#[error("The request is not valid: {0}")]
6161
BadRequest(String),
62+
63+
#[error("The transaction has been reverted: {0}")]
64+
TransactionReverted(String),
6265
}
6366

6467
/// Variant of `TransactionPool` error
@@ -113,10 +116,16 @@ impl From<EvmError> for jsonrpc_core::error::Error {
113116
EvmError::NotAuthorized => -32002, // NO_AUTHOR
114117
_ => -32015, // EXECUTION_ERROR
115118
};
119+
120+
let data = match &err {
121+
EvmError::TransactionReverted(msg) => Some(msg),
122+
_ => None,
123+
};
124+
116125
Error {
117126
code: ErrorCode::ServerError(code),
118127
message: err.to_string(),
119-
data: None,
128+
data: data.map(|s| s.as_str().into()),
120129
}
121130
}
122131
}

0 commit comments

Comments
 (0)