Exception: Stackify::StackifiedError
- Defined in:
- lib/stackify/error.rb
Constant Summary collapse
- CONTEXT_PROPERTIES =
{ 'user' => 'current_user'}
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
Instance Method Summary collapse
- #backtrace ⇒ Object
- #error_type ⇒ Object
-
#initialize(ex, error_binding) ⇒ StackifiedError
constructor
A new instance of StackifiedError.
- #message ⇒ Object
- #source_method ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(ex, error_binding) ⇒ StackifiedError
Returns a new instance of StackifiedError.
13 14 15 16 17 18 19 |
# File 'lib/stackify/error.rb', line 13 def initialize(ex, error_binding) @exception = ex @context = {} CONTEXT_PROPERTIES.each do |key , value| @context[key] = error_binding.eval(value) if error_binding.local_variable_defined?(value.to_sym) end end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
11 12 13 |
# File 'lib/stackify/error.rb', line 11 def context @context end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
11 12 13 |
# File 'lib/stackify/error.rb', line 11 def exception @exception end |
Instance Method Details
#backtrace ⇒ Object
21 22 23 |
# File 'lib/stackify/error.rb', line 21 def backtrace Stackify::Backtrace.stacktrace @exception.backtrace end |
#error_type ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/stackify/error.rb', line 33 def error_type if @exception.class.to_s == 'StringException' @exception..split(" ")[0].to_s else @exception.class end end |
#message ⇒ Object
29 30 31 |
# File 'lib/stackify/error.rb', line 29 def @exception. end |
#source_method ⇒ Object
25 26 27 |
# File 'lib/stackify/error.rb', line 25 def source_method Stackify::Backtrace.method_name @exception.try{ |e| e.backtrace[0] } end |
#to_h ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/stackify/error.rb', line 41 def to_h env = Stackify::EnvDetails.instance data = { 'OccurredEpochMillis' => Time.now.to_f*1000, 'Error' => { 'InnerError' => @exception.try(:cause), 'StackTrace' => backtrace, 'Message' => , 'ErrorType' => error_type.to_s, 'ErrorTypeCode' => nil, 'Data' => {}, 'SourceMethod' => source_method, }, 'EnvironmentDetail' => env.auth_info, 'CustomerName' => 'Customer', 'UserName' => @context.fetch('user', '') } web_request_details = env.request_details.try{ |d| d.fetch('webrequest_details', '') } if web_request_details.nil? data['WebRequestDetail'] = web_request_details end server_variables = env.request_details.try{ |d| d.fetch('server_variables', '') } if server_variables.nil? data['ServerVariables'] = server_variables end data end |