Skip to content

Commit

Permalink
- Moved MAX_EXCEPTIONS_TO_UNWRAP back into Report module
Browse files Browse the repository at this point in the history
- Added max_exceptions as argument to generate_raw_exceptions with default 5
  • Loading branch information
Cawllec committed Mar 19, 2018
1 parent 5a6dd12 commit fac2c7a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 2 additions & 4 deletions lib/bugsnag/helpers/exceptions.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
module Bugsnag
module Helpers
MAX_EXCEPTIONS_TO_UNWRAP = 5

class << self
##
# Generates a list of exceptions
def generate_raw_exceptions(exception)
def generate_raw_exceptions(exception, max_exceptions = 5)
exceptions = []

ex = exception
while !ex.nil? && !exceptions.include?(ex) && exceptions.length < MAX_EXCEPTIONS_TO_UNWRAP
while !ex.nil? && !exceptions.include?(ex) && exceptions.length < max_exceptions

unless ex.is_a? Exception
if ex.respond_to?(:to_exception)
Expand Down
4 changes: 3 additions & 1 deletion lib/bugsnag/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class Report
USER_SPECIFIED_SEVERITY = "userSpecifiedSeverity"
USER_CALLBACK_SET_SEVERITY = "userCallbackSetSeverity"

MAX_EXCEPTIONS_TO_UNWRAP = 5

CURRENT_PAYLOAD_VERSION = "4.0"

attr_reader :unhandled
Expand Down Expand Up @@ -43,7 +45,7 @@ def initialize(exception, passed_configuration, auto_notify=false)

self.configuration = passed_configuration

self.raw_exceptions = Bugsnag::Helpers.generate_raw_exceptions(exception)
self.raw_exceptions = Bugsnag::Helpers.generate_raw_exceptions(exception, MAX_EXCEPTIONS_TO_UNWRAP)
self.exceptions = generate_exception_list

self.api_key = configuration.api_key
Expand Down

0 comments on commit fac2c7a

Please sign in to comment.