Exception: Octobat::OctobatError
- Inherits:
-
StandardError
- Object
- StandardError
- Octobat::OctobatError
- Defined in:
- lib/octobat/errors/octobat_error.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#http_body ⇒ Object
readonly
Returns the value of attribute http_body.
-
#http_status ⇒ Object
readonly
Returns the value of attribute http_status.
-
#json_body ⇒ Object
readonly
Returns the value of attribute json_body.
-
#message ⇒ Object
Returns the value of attribute message.
Instance Method Summary collapse
- #generate_message_from_error ⇒ Object
-
#initialize(error = nil, http_status = nil, http_body = nil, json_body = nil) ⇒ OctobatError
constructor
A new instance of OctobatError.
- #serialize_errors_from(err) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(error = nil, http_status = nil, http_body = nil, json_body = nil) ⇒ OctobatError
Returns a new instance of OctobatError.
9 10 11 12 13 14 |
# File 'lib/octobat/errors/octobat_error.rb', line 9 def initialize(error=nil, http_status=nil, http_body=nil, json_body=nil) @error = error @http_status = http_status @http_body = http_body @json_body = json_body end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
4 5 6 |
# File 'lib/octobat/errors/octobat_error.rb', line 4 def error @error end |
#http_body ⇒ Object (readonly)
Returns the value of attribute http_body.
6 7 8 |
# File 'lib/octobat/errors/octobat_error.rb', line 6 def http_body @http_body end |
#http_status ⇒ Object (readonly)
Returns the value of attribute http_status.
5 6 7 |
# File 'lib/octobat/errors/octobat_error.rb', line 5 def http_status @http_status end |
#json_body ⇒ Object (readonly)
Returns the value of attribute json_body.
7 8 9 |
# File 'lib/octobat/errors/octobat_error.rb', line 7 def json_body @json_body end |
#message ⇒ Object
Returns the value of attribute message.
3 4 5 |
# File 'lib/octobat/errors/octobat_error.rb', line 3 def @message end |
Instance Method Details
#generate_message_from_error ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/octobat/errors/octobat_error.rb', line 25 def return "" if @error.nil? a = [] @error.each_key do |k| msg = k.eql?(:global) ? "" : "#{k.to_s}: " msg << "#{serialize_errors_from(@error[k])}" a << msg end a.join(". ") end |
#serialize_errors_from(err) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/octobat/errors/octobat_error.rb', line 38 def serialize_errors_from(err) a = [] err.each do |e| a << "#{e[:details]}" end a.join(', ') end |
#to_s ⇒ Object
20 21 22 23 |
# File 'lib/octobat/errors/octobat_error.rb', line 20 def to_s status_string = @http_status.nil? ? "" : "(Status #{@http_status}) " "#{status_string}#{}" end |