Exception: Knock::KnockError
- Inherits:
-
StandardError
- Object
- StandardError
- Knock::KnockError
- Defined in:
- lib/knock/errors.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#http_status ⇒ Object
readonly
Returns the value of attribute http_status.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
Instance Method Summary collapse
-
#initialize(message: nil, error: nil, error_description: nil, http_status: nil, request_id: nil) ⇒ KnockError
constructor
A new instance of KnockError.
- #to_s ⇒ Object
Constructor Details
#initialize(message: nil, error: nil, error_description: nil, http_status: nil, request_id: nil) ⇒ KnockError
Returns a new instance of KnockError.
6 7 8 9 10 11 12 |
# File 'lib/knock/errors.rb', line 6 def initialize(message: nil, error: nil, error_description: nil, http_status: nil, request_id: nil) @message = @error = error @error_description = error_description @http_status = http_status @request_id = request_id end |
Instance Attribute Details
#http_status ⇒ Object (readonly)
Returns the value of attribute http_status.
3 4 5 |
# File 'lib/knock/errors.rb', line 3 def http_status @http_status end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
4 5 6 |
# File 'lib/knock/errors.rb', line 4 def request_id @request_id end |
Instance Method Details
#to_s ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/knock/errors.rb', line 14 def to_s status_string = @http_status.nil? ? "" : "Status #{@http_status}, " id_string = @request_id.nil? ? "" : " - request ID: #{@request_id}" if @error && @error_description error_string = "error: #{@error}, error_description: #{@error_description}" "#{status_string}#{error_string}#{id_string}" elsif @error "#{status_string}#{@error}#{id_string}" else "#{status_string}#{@message}#{id_string}" end end |