Exception: ViewModel::WrappedExceptionError

Inherits:
AbstractError
  • Object
show all
Defined in:
lib/view_model/error.rb

Overview

Error type to wrap an arbitrary exception as a renderable ViewModel::AbstractError

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractError

#aggregation?, #causes, #meta, #title, #to_s, #view

Constructor Details

#initialize(exception, status, code) ⇒ WrappedExceptionError

Returns a new instance of WrappedExceptionError.



162
163
164
165
166
167
# File 'lib/view_model/error.rb', line 162

def initialize(exception, status, code)
  @exception = exception
  @status    = status
  @code      = code
  super()
end

Instance Attribute Details

#exceptionObject (readonly)

Returns the value of attribute exception.



160
161
162
# File 'lib/view_model/error.rb', line 160

def exception
  @exception
end

#statusObject (readonly)

Returns the value of attribute status.



160
161
162
# File 'lib/view_model/error.rb', line 160

def status
  @status
end

Instance Method Details

#codeObject



173
174
175
# File 'lib/view_model/error.rb', line 173

def code
  @code || "Exception.#{exception.class.name}"
end

#detailObject



169
170
171
# File 'lib/view_model/error.rb', line 169

def detail
  exception.message
end