Class: ConvenientService::Support::BacktraceCleaner Private
- Inherits:
-
Dependencies::Extractions::ActiveSupportBacktraceCleaner::BacktraceCleaner
- Object
- Dependencies::Extractions::ActiveSupportBacktraceCleaner::BacktraceCleaner
- ConvenientService::Support::BacktraceCleaner
- Defined in:
- lib/convenient_service/support/backtrace_cleaner.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Other gems are also trying to integrate with Rails Backtrace Cleaner.
Rails v8.0.2 Backtrace Cleaner descendant. Has Convenient Service specific silencer - ‘add_convenient_service_silencer`. By default, it uses only `add_stdlib_silencer` and `add_convenient_service_silencer`.
Instance Method Summary collapse
-
#add_convenient_service_silencer ⇒ void
private
Since Convenient Service is using middleware chains under the hood, exception backtraces may be huge.
-
#clean(backtrace, *args) ⇒ Array<String>
private
Works exactly in the same way as the original ‘clean`, except it falls back to the original backtrace in case of any exceptions inside filters or silencers.
- #initialize ⇒ void constructor private
Methods inherited from Dependencies::Extractions::ActiveSupportBacktraceCleaner::BacktraceCleaner
#add_filter, #add_silencer, #clean_frame, #remove_filters!, #remove_silencers!
Constructor Details
#initialize ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
‘ConvenientService::Support::BacktraceCleaner` intentionally does NOT exclude external gems lines from backtrace.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/convenient_service/support/backtrace_cleaner.rb', line 38 def initialize(...) super remove_filters! remove_silencers! ## # NOTE: Uses `::RbConfig` to resolve stdlib directory. # - https://idiosyncratic-ruby.com/42-ruby-config.html # - https://github.com/ruby/ruby/blob/master/tool/mkconfig.rb # add_stdlib_silencer ## # NOTE: # add_convenient_service_silencer end |
Instance Method Details
#add_convenient_service_silencer ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
To bring back Convenient Service lines to backtraces, use the ‘remove_silencers` or check the `CleansExceptionBacktrace` plugin.
This method returns an undefined value.
Since Convenient Service is using middleware chains under the hood, exception backtraces may be huge. As a consequence, it takes too much time during the debugging process to find the application line of code that causes the exception. This silencer removes all Convenient Service lines from backtraces.
93 94 95 96 97 98 99 100 |
# File 'lib/convenient_service/support/backtrace_cleaner.rb', line 93 def add_convenient_service_silencer add_silencer do |line| next false if line.start_with?(::ConvenientService.examples_root.to_s) next false if line.start_with?(::ConvenientService.spec_root.to_s) line.start_with?(::ConvenientService.root.to_s) end end |
#clean(backtrace, *args) ⇒ Array<String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Works exactly in the same way as the original ‘clean`, except it falls back to the original backtrace in case of any exceptions inside filters or silencers. Also returns an empty array, when `backtrace` is `nil`.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/convenient_service/support/backtrace_cleaner.rb', line 115 def clean(backtrace, *args) if backtrace.nil? ::ConvenientService.logger.warn { "[BacktraceCleaner] `nil` backtrace | Empty array is used as fallback" } return [] end begin super rescue ::ConvenientService.logger.warn { "[BacktraceCleaner] Some filter or silencer is broken | Original backtrace is used as fallback" } backtrace end end |