Skip to content

Commit

Permalink
airbrake-ruby: reraise SystemExit instead of raising Airbrak::Error
Browse files Browse the repository at this point in the history
Fixes #28 ("Airbrake::Error: the 'default' notifier isn't configured"
thrown after unsuccessful specs)

This fixes issues with the Rake integration. There was a [similar
issue][1] to a bug with the Rake integration reported a couple of weeks
ago. The change presented here fixes both issues by reraising
`SystemExit`, which propagates it and gets handled by Ruby.

[1]: #13
  • Loading branch information
kyrylo committed Jan 18, 2016
1 parent 53134c8 commit a801ba5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Airbrake Ruby Changelog
([#21](https://github.com/airbrake/airbrake-ruby/pull/21))
* Made the asynchronous delivery mechanism more robust
([#26](https://github.com/airbrake/airbrake-ruby/pull/26))
* Improved `SystemExit` handling by ignoring it on a different level, which
fixed issues with the Rake integration for the [airbrake gem][airbrake-gem]
gem ([#32](https://github.com/airbrake/airbrake-ruby/pull/32))

### [v1.0.2][v1.0.2] (January 3, 2016)

Expand Down
8 changes: 5 additions & 3 deletions lib/airbrake-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,10 @@ def call_notifier(notifier, method, *args, &block)
if @notifiers.key?(notifier)
@notifiers[notifier].__send__(method, *args, &block)
else
# If we raise SystemExit, the Ruby process can gracefully quit without
# the unwanted Airbrake::Error.
raise args.first if args.first.class == SystemExit

raise Airbrake::Error,
"the '#{notifier}' notifier isn't configured"
end
Expand All @@ -289,7 +293,5 @@ def call_notifier(notifier, method, *args, &block)

# Notify of unhandled exceptions, if there were any, but ignore SystemExit.
at_exit do
if $ERROR_INFO && $ERROR_INFO.class != SystemExit
Airbrake.notify_sync($ERROR_INFO)
end
Airbrake.notify_sync($ERROR_INFO) if $ERROR_INFO
end

0 comments on commit a801ba5

Please sign in to comment.