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 |
# File 'lib/stackify/error.rb', line 33 def error_type @exception.class 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
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/stackify/error.rb', line 37 def to_h env = Stackify::EnvDetails.instance { '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, 'WebRequestDetail' => env.request_details.try{ |d| d.fetch('webrequest_details', '') }, 'ServerVariables' => env.request_details.try{ |d| d.fetch('server_variables', '') }, 'CustomerName' => 'Customer', 'UserName' => @context.fetch('user', '') } end |