Class: GlobalErrorHandler::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/global_error_handler/parser.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, exception, controller) ⇒ Parser

Returns a new instance of Parser.



5
6
7
8
9
10
11
# File 'lib/global_error_handler/parser.rb', line 5

def initialize(env, exception, controller)
  @env = env
  @exception = exception
  @controller = controller
  @request = ActionDispatch::Request.new(@env)
  @info_hash = Hashie::Mash.new
end

Instance Attribute Details

#info_hashObject (readonly)

Returns the value of attribute info_hash.



3
4
5
# File 'lib/global_error_handler/parser.rb', line 3

def info_hash
  @info_hash
end

Instance Method Details

#parseObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/global_error_handler/parser.rb', line 13

def parse
  info_hash.error_class    = @exception.class.to_s.strip
  info_hash.error_message  = @exception.message.to_s.strip
  info_hash.error_trace    = form_backtrace @exception.backtrace
  info_hash.request_method = @request.method
  info_hash.request_params = @request.params.to_s
  info_hash.target_url     = @request.url
  info_hash.referer_url    = @request.referer
  info_hash.user_agent     = @request.user_agent
  info_hash.      = .to_s
  info_hash.timestamp      = Time.current.utc
  self
end