|
1 | 1 | require 'uri' |
2 | 2 |
|
3 | 3 | module Raven |
4 | | - class Configuration |
| 4 | + class Configuration # rubocop:disable Metrics/ClassLength |
5 | 5 | # Directories to be recognized as part of your app. e.g. if you |
6 | 6 | # have an `engines` dir at the root of your project, you may want |
7 | 7 | # to set this to something like /(app|config|engines|lib)/ |
@@ -31,6 +31,10 @@ class Configuration |
31 | 31 | # You should probably append to this rather than overwrite it. |
32 | 32 | attr_accessor :excluded_exceptions |
33 | 33 |
|
| 34 | + # Boolean to check nested exceptions when deciding if to exclude. Defaults to false |
| 35 | + attr_accessor :inspect_exception_causes_for_exclusion |
| 36 | + alias inspect_exception_causes_for_exclusion? inspect_exception_causes_for_exclusion |
| 37 | + |
34 | 38 | # DSN component - set automatically if DSN provided |
35 | 39 | attr_accessor :host |
36 | 40 |
|
@@ -205,6 +209,7 @@ def initialize |
205 | 209 | self.environments = [] |
206 | 210 | self.exclude_loggers = [] |
207 | 211 | self.excluded_exceptions = IGNORE_DEFAULT.dup |
| 212 | + self.inspect_exception_causes_for_exclusion = false |
208 | 213 | self.linecache = ::Raven::LineCache.new |
209 | 214 | self.logger = ::Raven::Logger.new(STDOUT) |
210 | 215 | self.open_timeout = 1 |
@@ -349,14 +354,24 @@ def detect_release |
349 | 354 | logger.error "Error detecting release: #{ex.message}" |
350 | 355 | end |
351 | 356 |
|
352 | | - def excluded_exception?(exc) |
353 | | - excluded_exceptions.any? { |x| get_exception_class(x) === exc } |
| 357 | + def excluded_exception?(incoming_exception) |
| 358 | + excluded_exceptions.any? do |excluded_exception| |
| 359 | + matches_exception?(get_exception_class(excluded_exception), incoming_exception) |
| 360 | + end |
354 | 361 | end |
355 | 362 |
|
356 | 363 | def get_exception_class(x) |
357 | 364 | x.is_a?(Module) ? x : qualified_const_get(x) |
358 | 365 | end |
359 | 366 |
|
| 367 | + def matches_exception?(excluded_exception_class, incoming_exception) |
| 368 | + if inspect_exception_causes_for_exclusion? |
| 369 | + Raven::Utils::ExceptionCauseChain.exception_to_array(incoming_exception).any? { |cause| excluded_exception_class === cause } |
| 370 | + else |
| 371 | + excluded_exception_class === incoming_exception |
| 372 | + end |
| 373 | + end |
| 374 | + |
360 | 375 | # In Ruby <2.0 const_get can't lookup "SomeModule::SomeClass" in one go |
361 | 376 | def qualified_const_get(x) |
362 | 377 | x = x.to_s |
|
0 commit comments