diff --git a/CHANGELOG.md b/CHANGELOG.md index 924c217e..ac723153 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,9 @@ Airbrake Ruby Changelog ### master * Improved parsing of backtraces - ([#25](https://github.com/airbrake/airbrake-ruby/pull/25)) + ([#25](https://github.com/airbrake/airbrake-ruby/pull/25), + [#29](https://github.com/airbrake/airbrake-ruby/pull/29), + [#30](https://github.com/airbrake/airbrake-ruby/pull/30)) * Made sure that generated notices always have a backtrace ([#21](https://github.com/airbrake/airbrake-ruby/pull/21)) * Made the asynchronous delivery mechanism more robust diff --git a/lib/airbrake-ruby/backtrace.rb b/lib/airbrake-ruby/backtrace.rb index 4f4892ee..cd19e5c1 100644 --- a/lib/airbrake-ruby/backtrace.rb +++ b/lib/airbrake-ruby/backtrace.rb @@ -51,6 +51,8 @@ module Backtrace # parse # @return [ArrayString,Integer}>] the parsed backtrace def self.parse(exception) + return [] if exception.backtrace.nil? || exception.backtrace.none? + regexp = if java_exception?(exception) JAVA_STACKFRAME_REGEXP else diff --git a/lib/airbrake-ruby/nested_exception.rb b/lib/airbrake-ruby/nested_exception.rb index 5d668a31..4b5f3f9e 100644 --- a/lib/airbrake-ruby/nested_exception.rb +++ b/lib/airbrake-ruby/nested_exception.rb @@ -16,7 +16,7 @@ def as_json unwind_exceptions.map do |exception| { type: exception.class.name, message: exception.message, - backtrace: parse_backtrace(exception) } + backtrace: Backtrace.parse(exception) } end end @@ -33,10 +33,5 @@ def unwind_exceptions exception_list end - - def parse_backtrace(exception) - return if exception.backtrace.nil? || exception.backtrace.none? - Backtrace.parse(exception) - end end end diff --git a/spec/nested_exception.rb b/spec/nested_exception_spec.rb similarity index 95% rename from spec/nested_exception.rb rename to spec/nested_exception_spec.rb index 1602ee33..05694faa 100644 --- a/spec/nested_exception.rb +++ b/spec/nested_exception_spec.rb @@ -68,8 +68,8 @@ exceptions = nested_exception.as_json expect(exceptions.size).to eq(2) - expect(exceptions[0][:backtrace]).to be_nil - expect(exceptions[1][:backtrace]).to be_nil + expect(exceptions[0][:backtrace]).to be_empty + expect(exceptions[1][:backtrace]).to be_empty end end end