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?

Some types of error may be aggregations over multiple causes
def aggregation?
  false
end

def causes

If so, the causes of this error (as AbstractErrors)
def causes
  nil
end

def code

Unique symbol identifying this error type
def code
  'ViewModel.AbstractError'
end

def detail

Human-readable reason for use displaying this error.
def detail
  'ViewModel::AbstractError'
end

def exception

object, but sometimes an Error may be used to wrap an external 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

Additional information specific to this error type.
def meta
  {}
end

def status

HTTP status code most appropriate for this error
def status
  500
end

def title

Human-readable title for displaying this error
def title
  nil
end

def to_s

def to_s
  detail
end

def view

def view
  ViewModel::ErrorView.new(self)
end