class ViewModel::AbstractError
by ViewModel::ErrorView, which loosely follows errors in JSON-API.
type will be caught by ViewModel controllers and rendered in a standard format
Abstract base for renderable errors in ViewModel-based APIs. Errors of this
def aggregation?
def aggregation? false end
def causes
def causes nil end
def code
def code 'ViewModel.AbstractError' end
def detail
def detail 'ViewModel::AbstractError' end
def exception
The exception responsible for this error. In most cases, that should be this
def exception self end
def format_reference(viewmodel_ref)
def format_reference(viewmodel_ref) { ViewModel::TYPE_ATTRIBUTE => viewmodel_ref.viewmodel_class.view_name, ViewModel::ID_ATTRIBUTE => viewmodel_ref.model_id, } end
def format_references(viewmodel_refs)
def format_references(viewmodel_refs) viewmodel_refs.map do |viewmodel_ref| format_reference(viewmodel_ref) end end
def initialize
def initialize # `detail` is used to provide the exception message. However, it's not safe # to just override StandardError's `message` or `to_s` to call `detail`, # since some of Ruby's C implementation of Exceptions internally ignores # these methods and fetches the invisible internal `idMesg` attribute # instead. (!) # # This means that all fields necessary to derive the detail message must be # initialized before calling super(). super(detail) end
def meta
def meta {} end
def status
def status 500 end
def title
def title nil end
def to_s
def to_s detail end
def view
def view ViewModel::ErrorView.new(self) end