parse_error

Function parse_error 

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

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

Bitget API responses follow this format:

{
    "code": "40001",
    "msg": "Invalid API key",
    "data": null
}

§Arguments

  • response - The JSON response from Bitget API

§Returns

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

§Example

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

let response = json!({
    "code": "40001",
    "msg": "Invalid API key"
});

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