From 4a93088e1344536c866ac414cee98cb58126817b Mon Sep 17 00:00:00 2001 From: Taylor Lodge Date: Thu, 9 Mar 2017 10:56:57 +1300 Subject: [PATCH 1/2] Notify raygun when raygun4ruby raises an exception Try a single time to send an exception generated when track_exception is called to raygun with the original exceptions backtrace attached as custom data --- lib/raygun.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/raygun.rb b/lib/raygun.rb index 449bc3a..087e391 100644 --- a/lib/raygun.rb +++ b/lib/raygun.rb @@ -46,7 +46,7 @@ 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) @@ -54,6 +54,16 @@ def track_exception(exception_instance, env = {}) 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 From e3f8e5b2fe703f5ea3f9462479672cd6499e8888 Mon Sep 17 00:00:00 2001 From: Taylor Lodge Date: Thu, 9 Mar 2017 11:01:30 +1300 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b5b5cd..ff4ae33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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