Sha256: ba685a2ddcf4f9ed85976f1d08760c1d49c8bf28726cbbac523181fb45799ab3
Contents?: true
Size: 1.42 KB
Versions: 3
Compression:
Stored size: 1.42 KB
Contents
module Stackify class StackifiedError < StandardError CONTEXT_PROPERTIES = { 'user' => 'current_user'} attr_reader :context, :exception 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 def backtrace Stackify::Backtrace.stacktrace @exception.backtrace end def source_method Stackify::Backtrace.method_name @exception.try{ |e| e.backtrace[0] } end def message @exception.message end def error_type @exception.class end def to_h env = Stackify::EnvDetails.instance { 'OccurredEpochMillis' => Time.now.to_f*1000, 'Error' => { 'InnerError' => @exception.try(:cause), 'StackTrace' => backtrace, 'Message' => 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 end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
stackify-api-ruby-1.0.3 | lib/stackify/error.rb |
stackify-api-ruby-1.0.2 | lib/stackify/error.rb |
stackify-api-ruby-1.0.1 | lib/stackify/error.rb |