Class: GlobalErrorHandler::Parser

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, exception, controller) ⇒ Parser

Returns a new instance of Parser.



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

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

Instance Attribute Details

#info_hashObject (readonly)

Returns the value of attribute info_hash.



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

def info_hash
  @info_hash
end

Instance Method Details

#parseObject



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

def parse
  @info_hash[:error_class]    = @exception.class.to_s.strip
  @info_hash[:error_message]  = @exception.message.to_s.strip
  @info_hash[:error_trace]    = @exception.backtrace.join("\n")
  @info_hash[:request_method] = @request.method
  @info_hash[:request_params] = @request.params
  @info_hash[:target_url]     = @request.url
  @info_hash[:referer_url]    = @request.referer
  @info_hash[:user_agent]     = @request.user_agent
  @info_hash[:user_info]      = 
  @info_hash[:timestamp]      = Time.now.utc
  self
end