class JSONAPIErrors::HashRenderer

Attributes

exception[R]

Public Class Methods

new(exception) click to toggle source
# File lib/jsonapi_errors/hash_renderer.rb, line 5
def initialize(exception)
  @exception = exception
end

Public Instance Methods

render() click to toggle source
# File lib/jsonapi_errors/hash_renderer.rb, line 9
def render
  return unhandled_exception_error unless data = JSONAPIErrors::Configuration.matches.fetch(@exception.class.to_s, false)
  data.reverse_merge!({title: @exception.class.to_s, detail: @exception.message, status: "500"})
  {errors: [data]}
end

Private Instance Methods

unhandled_exception_error() click to toggle source
# File lib/jsonapi_errors/hash_renderer.rb, line 17
def unhandled_exception_error
  unhandled_exception_error! unless JSONAPIErrors::Configuration::catch_unhandled_exceptions
  {errors: [{title: "Unhandled exception", detail: "The Exception: #{@exception.class.name} #{@exception.message}. is not handled in configuration.matches.", status: "500"}]}
end
unhandled_exception_error!() click to toggle source
# File lib/jsonapi_errors/hash_renderer.rb, line 22
def unhandled_exception_error!
  raise @exception
end