Exception: Bitget::Error
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- Bitget::Error
- Defined in:
- lib/Bitget/Error.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#error_code ⇒ Object
Bitget answers most errors with a JSON body carrying its own code and message, which are more use than the HTTP ones.
- #error_message ⇒ Object
- #to_s ⇒ Object
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
8 9 10 |
# File 'lib/Bitget/Error.rb', line 8 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
8 9 10 |
# File 'lib/Bitget/Error.rb', line 8 def code @code end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
8 9 10 |
# File 'lib/Bitget/Error.rb', line 8 def @message end |
Instance Method Details
#error_code ⇒ Object
Bitget answers most errors with a JSON body carrying its own code and message, which are more use than the HTTP ones. Not all of them: a 418 arrives with an empty body and there is nothing to parse. Where the body says nothing the HTTP code and message answer instead, so that an error renders as something rather than as a pair of blanks.
18 19 20 |
# File 'lib/Bitget/Error.rb', line 18 def error_code @parsed_body['code'] || @code end |
#error_message ⇒ Object
22 23 24 |
# File 'lib/Bitget/Error.rb', line 22 def @parsed_body['msg'] || @parsed_body['message'] || @message end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/Bitget/Error.rb', line 26 def to_s "Bitget::Error: #{error_code} - #{}" end |