class Logux::ErrorRenderer

Attributes

exception[R]

Public Class Methods

new(exception) click to toggle source
# File lib/logux/error_renderer.rb, line 7
def initialize(exception)
  @exception = exception
end

Public Instance Methods

message() click to toggle source
# File lib/logux/error_renderer.rb, line 11
def message
  case exception
  when Logux::WithMetaError
    build_message(exception, exception.meta.id)
  when Logux::UnauthorizedError
    build_message(exception, exception.message)
  when StandardError
    # some runtime error that should be fixed
    render_stardard_error(exception)
  end
end

Private Instance Methods

build_message(exception, additional_info) click to toggle source
# File lib/logux/error_renderer.rb, line 33
def build_message(exception, additional_info)
  [
    exception.class.name.demodulize.camelize(:lower).gsub(/Error/, ''),
    additional_info
  ]
end
render_stardard_error(exception) click to toggle source
# File lib/logux/error_renderer.rb, line 25
def render_stardard_error(exception)
  if Logux.configuration.render_backtrace_on_error
    ['error', exception.message + "\n" + exception.backtrace.join("\n")]
  else
    ['error', 'Please check server logs for more information']
  end
end