Skip to content

Commit 87c2a08

Browse files
authored
feat: custom error codes (#5)
1 parent 690ce83 commit 87c2a08

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

relay_rpc/src/rpc.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ pub enum ValidationError {
5050
/// make sense of the problem.
5151
#[derive(Debug, thiserror::Error)]
5252
pub enum GenericError {
53+
#[error("Authorization error: {0}")]
54+
Authorization(BoxError),
55+
5356
/// Request parameters validation failed.
5457
#[error("Request validation error: {0}")]
5558
Validation(#[from] ValidationError),
@@ -74,11 +77,12 @@ pub enum GenericError {
7477
}
7578

7679
impl GenericError {
77-
/// The error code. These are mostly generic and carried over from the old
78-
/// `ts-relay`.
80+
/// The error code. These are the standard JSONRPC error codes. The Relay
81+
/// specific errors are in 3000-4999 range to align with the websocket close
82+
/// codes.
7983
pub fn code(&self) -> i32 {
80-
// Source: https://github.com/WalletConnect/rs-relay/issues/262
8184
match self {
85+
Self::Authorization(_) => 3000,
8286
Self::Serialization(_) => -32700,
8387
Self::Validation(_) => -32602,
8488
Self::RequestMethod => -32601,

0 commit comments

Comments
 (0)