Skip to content

Commit

Permalink
Merge pull request #104 from MindscapeHQ/log-raygun4ruby-exceptions-t…
Browse files Browse the repository at this point in the history
…o-raygun

Notify raygun when raygun4ruby raises an exception
  • Loading branch information
UberMouse authored Mar 8, 2017
2 parents 4e4aceb + e3f8e5b commit c3fb0a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Features:
- Added two new configuration options, `filter_payload_with_whitelist` and `whitelist_payload_shape`
- See [README.md](https://github.com/MindscapeHQ/raygun4ruby#filtering-the-payload-by-whitelist) for an example of how to use them
- When raygun4ruby encounters an exception trying to track an exception it will try once to send that exception to Raygun so you are notified

Bugfixes:
- raygun4ruby will no longer crash and suppress app exceptions when the API key is not configured
12 changes: 11 additions & 1 deletion lib/raygun.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,24 @@ def configured?
!!configuration.api_key
end

def track_exception(exception_instance, env = {})
def track_exception(exception_instance, env = {}, retry_count = 1)
if should_report?(exception_instance)
log("[Raygun] Tracking Exception...")
Client.new.track_exception(exception_instance, env)
end
rescue Exception => e
if configuration.failsafe_logger
failsafe_log("Problem reporting exception to Raygun: #{e.class}: #{e.message}\n\n#{e.backtrace.join("\n")}")
end

if retry_count > 0
new_exception = e.exception("raygun4ruby encountered an exception processing your exception")
new_exception.set_backtrace(e.backtrace)

env[:custom_data] ||= {}
env[:custom_data].merge!(original_stacktrace: exception_instance.backtrace)

track_exception(new_exception, env, retry_count - 1)
else
raise e
end
Expand Down

0 comments on commit c3fb0a0

Please sign in to comment.