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 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