Skip to content

Commit c3fb0a0

Browse files
authored
Merge pull request #104 from MindscapeHQ/log-raygun4ruby-exceptions-to-raygun
Notify raygun when raygun4ruby raises an exception
2 parents 4e4aceb + e3f8e5b commit c3fb0a0

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Features:
44
- Added two new configuration options, `filter_payload_with_whitelist` and `whitelist_payload_shape`
55
- See [README.md](https://github.com/MindscapeHQ/raygun4ruby#filtering-the-payload-by-whitelist) for an example of how to use them
6+
- When raygun4ruby encounters an exception trying to track an exception it will try once to send that exception to Raygun so you are notified
67

78
Bugfixes:
89
- raygun4ruby will no longer crash and suppress app exceptions when the API key is not configured

lib/raygun.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,24 @@ def configured?
4646
!!configuration.api_key
4747
end
4848

49-
def track_exception(exception_instance, env = {})
49+
def track_exception(exception_instance, env = {}, retry_count = 1)
5050
if should_report?(exception_instance)
5151
log("[Raygun] Tracking Exception...")
5252
Client.new.track_exception(exception_instance, env)
5353
end
5454
rescue Exception => e
5555
if configuration.failsafe_logger
5656
failsafe_log("Problem reporting exception to Raygun: #{e.class}: #{e.message}\n\n#{e.backtrace.join("\n")}")
57+
end
58+
59+
if retry_count > 0
60+
new_exception = e.exception("raygun4ruby encountered an exception processing your exception")
61+
new_exception.set_backtrace(e.backtrace)
62+
63+
env[:custom_data] ||= {}
64+
env[:custom_data].merge!(original_stacktrace: exception_instance.backtrace)
65+
66+
track_exception(new_exception, env, retry_count - 1)
5767
else
5868
raise e
5969
end

0 commit comments

Comments
 (0)