Module: Karafka::Web::Tracking::Helpers::ErrorInfo
- Included in:
- Consumers::Listeners::Errors, Producers::Listeners::Errors
- Defined in:
- lib/karafka/web/tracking/helpers/error_info.rb
Overview
Module containing some helper methods useful for extracting extra errors info
Instance Method Summary collapse
-
#extract_error_info(error) ⇒ Array<String, String, String>
Extracts the basic error info.
-
#extract_error_message(error) ⇒ String
Formatted exception message.
Instance Method Details
#extract_error_info(error) ⇒ Array<String, String, String>
Extracts the basic error info
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/karafka/web/tracking/helpers/error_info.rb', line 14 def extract_error_info(error) app_root = "#{::Karafka.root}/" gem_home = if ENV.key?('GEM_HOME') ENV['GEM_HOME'] else File.(File.join(Karafka.gem_root.to_s, '../')) end gem_home = "#{gem_home}/" backtrace = error.backtrace || [] backtrace.map! { |line| line.gsub(app_root, '') } backtrace.map! { |line| line.gsub(gem_home, '') } [ error.class.name, (error), backtrace.join("\n") ] end |
#extract_error_message(error) ⇒ String
Returns formatted exception message.
38 39 40 41 42 43 44 45 |
# File 'lib/karafka/web/tracking/helpers/error_info.rb', line 38 def (error) = error..to_s[0, 10_000] .force_encoding('utf-8') .scrub! if .respond_to?(:scrub!) rescue StandardError '!!! Error message extraction failed !!!' end |