Skip to content

Commit

Permalink
Update error codes (#1004)
Browse files Browse the repository at this point in the history
* chore: update error code

* chore: format

* chore: try fix ci

* chore: fix ci
  • Loading branch information
boundless-forest authored Feb 9, 2023
1 parent 5faac4f commit f542a00
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions test-utils/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub fn parse_error(id: Id) -> String {

pub fn oversized_request(max_limit: u32) -> String {
format!(
r#"{{"jsonrpc":"2.0","error":{{"code":-32701,"message":"Request is too big","data":"Exceeded max limit of {max_limit}"}},"id":null}}"#
r#"{{"jsonrpc":"2.0","error":{{"code":-32007,"message":"Request is too big","data":"Exceeded max limit of {max_limit}"}},"id":null}}"#
)
}

Expand All @@ -83,7 +83,7 @@ pub fn batches_not_supported() -> String {

pub fn oversized_response(id: Id, max_limit: u32) -> String {
format!(
r#"{{"jsonrpc":"2.0","error":{{"code":-32702,"message":"Response is too big","data":"Exceeded max limit of {}"}},"id":{}}}"#,
r#"{{"jsonrpc":"2.0","error":{{"code":-32008,"message":"Response is too big","data":"Exceeded max limit of {}"}},"id":{}}}"#,
max_limit,
serde_json::to_string(&id).unwrap(),
)
Expand Down
20 changes: 10 additions & 10 deletions types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,20 +168,14 @@ impl<'a> From<CallError> for ErrorObject<'a> {

/// Parse error code.
pub const PARSE_ERROR_CODE: i32 = -32700;
/// Oversized request error code.
pub const OVERSIZED_REQUEST_CODE: i32 = -32701;
/// Oversized response error code.
pub const OVERSIZED_RESPONSE_CODE: i32 = -32702;
/// Internal error code.
pub const INTERNAL_ERROR_CODE: i32 = -32603;
/// Invalid params error code.
pub const INVALID_PARAMS_CODE: i32 = -32602;
/// Invalid request error code.
pub const INVALID_REQUEST_CODE: i32 = -32600;
/// Method not found error code.
pub const METHOD_NOT_FOUND_CODE: i32 = -32601;
/// Server is busy error code.
pub const SERVER_IS_BUSY_CODE: i32 = -32604;
/// Invalid params error code.
pub const INVALID_PARAMS_CODE: i32 = -32602;
/// Internal error code.
pub const INTERNAL_ERROR_CODE: i32 = -32603;
/// Custom server error when a call failed.
pub const CALL_EXECUTION_FAILED_CODE: i32 = -32000;
/// Unknown error.
Expand All @@ -190,6 +184,12 @@ pub const UNKNOWN_ERROR_CODE: i32 = -32001;
pub const BATCHES_NOT_SUPPORTED_CODE: i32 = -32005;
/// Subscription limit per connection was exceeded.
pub const TOO_MANY_SUBSCRIPTIONS_CODE: i32 = -32006;
/// Oversized request error code.
pub const OVERSIZED_REQUEST_CODE: i32 = -32007;
/// Oversized response error code.
pub const OVERSIZED_RESPONSE_CODE: i32 = -32008;
/// Server is busy error code.
pub const SERVER_IS_BUSY_CODE: i32 = -32009;

/// Parse error message
pub const PARSE_ERROR_MSG: &str = "Parse error";
Expand Down

0 comments on commit f542a00

Please sign in to comment.