Skip to content

Commit

Permalink
Merge pull request #30 from airbrake/improve-frame-parser
Browse files Browse the repository at this point in the history
backtrace: handle empty functions
  • Loading branch information
kyrylo committed Jan 18, 2016
2 parents 90f60fb + 7a575b2 commit b6b7ba1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/airbrake-ruby/backtrace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module Backtrace
:
(?<line>\d+) # Matches '43'
:in\s
`(?<function>.+)' # Matches "`block (3 levels) in <top (required)>'"
`(?<function>.*)' # Matches "`block (3 levels) in <top (required)>'"
\z}x

##
Expand Down
18 changes: 18 additions & 0 deletions spec/backtrace_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,23 @@
to raise_error(Airbrake::Error, /can't parse/)
end
end

context "given a backtrace with an empty function" do
let(:bt) do
["/airbrake-ruby/vendor/jruby/1.9/gems/rspec-core-3.4.1/exe/rspec:3:in `'"]
end

let(:ex) { AirbrakeTestError.new.tap { |e| e.set_backtrace(bt) } }

let(:parsed_backtrace) do
[{ file: '/airbrake-ruby/vendor/jruby/1.9/gems/rspec-core-3.4.1/exe/rspec',
line: 3,
function: '' }]
end

it "returns a properly formatted array of hashes" do
expect(described_class.parse(ex)).to eq(parsed_backtrace)
end
end
end
end

0 comments on commit b6b7ba1

Please sign in to comment.