Exception: Bybit::ApiError
Overview
Raised when the server returns HTTP 200 + retCode != 0 (the V5 norm), or when a transport-level error is enriched with a Bybit body payload. Accepts either a V5 response Hash (extracts retCode/retMsg/result/time) or a plain String message (used for HTTP-status mapping when the CDN/WAF returns a non-JSON body — e.g. 401/403/429 → AuthError/RateLimitError without a decodable retCode).
Direct Known Subclasses
Instance Attribute Summary collapse
-
#http_status ⇒ Object
readonly
Returns the value of attribute http_status.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#ret_code ⇒ Object
readonly
Returns the value of attribute ret_code.
-
#ret_msg ⇒ Object
readonly
Returns the value of attribute ret_msg.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
-
#initialize(response, http_status: nil) ⇒ ApiError
constructor
A new instance of ApiError.
Constructor Details
#initialize(response, http_status: nil) ⇒ ApiError
Returns a new instance of ApiError.
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/bybit/error.rb', line 32 def initialize(response, http_status: nil) @http_status = http_status if response.is_a?(Hash) @ret_code = response['retCode'] @ret_msg = response['retMsg'] @result = response['result'] @time = response['time'] super("[#{@ret_code}] #{@ret_msg}") else super(response.to_s) end end |
Instance Attribute Details
#http_status ⇒ Object (readonly)
Returns the value of attribute http_status.
30 31 32 |
# File 'lib/bybit/error.rb', line 30 def http_status @http_status end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
30 31 32 |
# File 'lib/bybit/error.rb', line 30 def result @result end |
#ret_code ⇒ Object (readonly)
Returns the value of attribute ret_code.
30 31 32 |
# File 'lib/bybit/error.rb', line 30 def ret_code @ret_code end |
#ret_msg ⇒ Object (readonly)
Returns the value of attribute ret_msg.
30 31 32 |
# File 'lib/bybit/error.rb', line 30 def ret_msg @ret_msg end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
30 31 32 |
# File 'lib/bybit/error.rb', line 30 def time @time end |