Exception: ActivePostgrest::Error

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Error

Returns a new instance of Error.



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

def initialize(response)
  body         = response.body.is_a?(Hash) ? response.body : {}
  @http_status = response.status
  @code        = body['code']
  @details     = body['details']
  @hint        = body['hint']
  super(body['message'] || "HTTP #{response.status}")
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



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

def code
  @code
end

#detailsObject (readonly)

Returns the value of attribute details.



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

def details
  @details
end

#hintObject (readonly)

Returns the value of attribute hint.



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

def hint
  @hint
end

#http_statusObject (readonly)

Returns the value of attribute http_status.



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

def http_status
  @http_status
end