Class: Logux::ErrorRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/logux/error_renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exception) ⇒ ErrorRenderer

Returns a new instance of ErrorRenderer.



7
8
9
# File 'lib/logux/error_renderer.rb', line 7

def initialize(exception)
  @exception = exception
end

Instance Attribute Details

#exceptionObject (readonly)

Returns the value of attribute exception.



5
6
7
# File 'lib/logux/error_renderer.rb', line 5

def exception
  @exception
end

Instance Method Details

#messageObject



11
12
13
14
15
16
17
18
19
20
21
# 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