Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nested_exception: fix backtrace parsing #29

Merged
merged 1 commit into from
Jan 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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