parse_error

Function parse_error 

Source
pub fn parse_error(response: &Value) -> Error
Expand description

Parses a Bybit API error response and converts it to a ccxt-core Error.

Bybit API responses follow this format:

{
    "retCode": 10003,
    "retMsg": "Invalid API key",
    "result": {},
    "time": 1234567890123
}

§Arguments

  • response - The JSON response from Bybit API

§Returns

A ccxt-core Error mapped from the Bybit error code.

§Example

use ccxt_exchanges::bybit::error::parse_error;
use serde_json::json;

let response = json!({
    "retCode": 10003,
    "retMsg": "Invalid API key"
});

let error = parse_error(&response);
assert!(error.as_authentication().is_some());