Exception: Toolx::Core::Errors::ApiError

Inherits:
AppError
  • Object
show all
Defined in:
lib/toolx/core/errors/api_error.rb

Instance Attribute Summary collapse

Attributes included from NestedError

#nested, #raw_backtrace

Instance Method Summary collapse

Methods included from NestedError

#set_backtrace

Constructor Details

#initialize(details = nil) ⇒ ApiError

Returns a new instance of ApiError.



7
8
9
10
# File 'lib/toolx/core/errors/api_error.rb', line 7

def initialize(details = nil)
  @details = details || {}
  super(@details[:message] || error_name)
end

Instance Attribute Details

#detailsObject (readonly)

Returns the value of attribute details.



5
6
7
# File 'lib/toolx/core/errors/api_error.rb', line 5

def details
  @details
end

Instance Method Details

#message_namespaceObject



12
13
14
# File 'lib/toolx/core/errors/api_error.rb', line 12

def message_namespace
  @message_namespace ||= self.class.to_s.deconstantize.underscore.tr!('/', '.')
end

#statusObject



16
17
18
# File 'lib/toolx/core/errors/api_error.rb', line 16

def status
  @status ||= details[:status] || error_name.to_sym
end