Exception: Apia::ErrorExceptionError

Inherits:
RuntimeError show all
Defined in:
lib/apia/errors/error_exception_error.rb

Overview

This is the error exception that must be raised when you wish to raise an error. It should be initialized with the Apia::Error class that you wish to raise.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_class, fields = {}) ⇒ ErrorExceptionError

Returns a new instance of ErrorExceptionError.



14
15
16
17
# File 'lib/apia/errors/error_exception_error.rb', line 14

def initialize(error_class, fields = {})
  @error_class = error_class
  @fields = fields
end

Instance Attribute Details

#error_classObject (readonly)

Returns the value of attribute error_class.



11
12
13
# File 'lib/apia/errors/error_exception_error.rb', line 11

def error_class
  @error_class
end

#fieldsObject (readonly)

Returns the value of attribute fields.



12
13
14
# File 'lib/apia/errors/error_exception_error.rb', line 12

def fields
  @fields
end

Instance Method Details

#hashObject



23
24
25
26
27
28
29
# File 'lib/apia/errors/error_exception_error.rb', line 23

def hash
  {
    code: @error_class.definition.code,
    description: @error_class.definition.description,
    detail: @error_class.definition.fields.generate_hash(@fields)
  }
end

#http_statusObject



19
20
21
# File 'lib/apia/errors/error_exception_error.rb', line 19

def http_status
  @error_class.definition.http_status || 500
end