Skip to content

Commit

Permalink
fix(api): Change error code for Web3Error::NotImplemented (#1521)
Browse files Browse the repository at this point in the history
## What ❔

Changes the error code for `Web3Error::NotImplemented` from
`InternalError` to `MethodNotFound`.

## Why ❔

Better representation of the nature of an error. Useful for better
error-handling on the client side.

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [ ] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [ ] Tests for the changes have been added / updated.
- [ ] Documentation comments have been added / updated.
- [ ] Code has been formatted via `zk fmt` and `zk lint`.
- [ ] Spellcheck has been run via `zk spellcheck`.
- [ ] Linkcheck has been run via `zk linkcheck`.
  • Loading branch information
popzxc committed Mar 30, 2024
1 parent 132a169 commit 0a13602
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ impl MethodTracer {
_ => None,
};
let code = match err {
Web3Error::InternalError(_) | Web3Error::NotImplemented => {
ErrorCode::InternalError.code()
}
Web3Error::NotImplemented => ErrorCode::MethodNotFound.code(),
Web3Error::InternalError(_) => ErrorCode::InternalError.code(),
Web3Error::NoBlock
| Web3Error::PrunedBlock(_)
| Web3Error::PrunedL1Batch(_)
Expand Down
2 changes: 1 addition & 1 deletion core/lib/zksync_core/src/api_server/web3/tests/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ async fn log_filter_changes_with_block_boundaries() {

fn assert_not_implemented<T: Debug>(result: Result<T, Error>) {
assert_matches!(result, Err(Error::Call(e)) => {
assert_eq!(e.code(), ErrorCode::InternalError.code());
assert_eq!(e.code(), ErrorCode::MethodNotFound.code());
assert_eq!(e.message(), "Not implemented");
});
}
Expand Down

0 comments on commit 0a13602

Please sign in to comment.