Exception: Marinetraffic::MarinetrafficError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/marinetraffic/errors/marinetraffic_error.rb

Direct Known Subclasses

APIError, AuthenticationError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, http_status = nil, http_body = nil, http_headers = nil, error_code = nil) ⇒ MarinetrafficError

Returns a new instance of MarinetrafficError.



9
10
11
12
13
14
15
# File 'lib/marinetraffic/errors/marinetraffic_error.rb', line 9

def initialize(message=nil, http_status=nil, http_body=nil, http_headers=nil, error_code=nil)
  @message = message
  @http_status = http_status
  @http_body = http_body
  @http_headers = http_headers || {}
  @error_code = error_code
end

Instance Attribute Details

#error_codeObject (readonly)

Returns the value of attribute error_code.



4
5
6
# File 'lib/marinetraffic/errors/marinetraffic_error.rb', line 4

def error_code
  @error_code
end

#http_bodyObject (readonly)

Returns the value of attribute http_body.



6
7
8
# File 'lib/marinetraffic/errors/marinetraffic_error.rb', line 6

def http_body
  @http_body
end

#http_headersObject (readonly)

Returns the value of attribute http_headers.



7
8
9
# File 'lib/marinetraffic/errors/marinetraffic_error.rb', line 7

def http_headers
  @http_headers
end

#http_statusObject (readonly)

Returns the value of attribute http_status.



5
6
7
# File 'lib/marinetraffic/errors/marinetraffic_error.rb', line 5

def http_status
  @http_status
end

#messageObject (readonly)

Returns the value of attribute message.



3
4
5
# File 'lib/marinetraffic/errors/marinetraffic_error.rb', line 3

def message
  @message
end

Instance Method Details

#to_sObject



17
18
19
20
# File 'lib/marinetraffic/errors/marinetraffic_error.rb', line 17

def to_s
  code_string = @error_code.nil? ? "" : "(Error #{@error_code}) "
  "#{code_string}#{@message}"
end