Skip to content

Commit

Permalink
Merge pull request #29 from airbrake/fix-backtrace-parsing
Browse files Browse the repository at this point in the history
nested_exception: fix backtrace parsing
  • Loading branch information
kyrylo committed Jan 18, 2016
2 parents b6b7ba1 + 934c81c commit 53134c8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lib/airbrake-ruby/backtrace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ module Backtrace
# parse
# @return [Array<Hash{Symbol=>String,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
Expand Down
7 changes: 1 addition & 6 deletions lib/airbrake-ruby/nested_exception.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
4 changes: 2 additions & 2 deletions spec/nested_exception.rb → spec/nested_exception_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 53134c8

Please sign in to comment.