Skip to content

Add centralized error reporting via Rage::Errors#275

Open
Digvijay-x1 wants to merge 1 commit intorage-rb:mainfrom
Digvijay-x1:centralized-error-reporting
Open

Add centralized error reporting via Rage::Errors#275
Digvijay-x1 wants to merge 1 commit intorage-rb:mainfrom
Digvijay-x1:centralized-error-reporting

Conversation

@Digvijay-x1
Copy link
Copy Markdown
Contributor

Allow users to register error reporters that receive all framework-caught exceptions, so they can forward them to services like Sentry or Bugsnag without manually rescuing in every component.

  Rage.configure do
    config.errors << SentryReporter.new
  end

Reporters can accept just the exception or an optional context hash. Signature detection uses Rage::Internal.build_arguments at registration time to keep the reporting path fast. Each reporter is called in its own rescue block so a broken reporter doesn't affect the rest. Duplicate prevention uses an instance variable on the exception (similar to Rails). Manually-created exceptions get a real backtrace via re-raise rather than set_backtrace(caller).
Hooked into all existing framework rescue sites: controllers, fiber wrapper, Cable connections/channels, Redis adapter, deferred tasks, event subscribers, SSE streams, and telemetry tracers.

Fixes #232

Allow users to register error reporters that receive all
framework-caught exceptions, so they can forward them to services
like Sentry or Bugsnag without manually rescuing in every component.
  Rage.configure do
    config.errors << SentryReporter.new
  end
Reporters can accept just the exception or an optional context hash.
Signature detection uses Rage::Internal.build_arguments at registration
time to keep the reporting path fast. Each reporter is called in its
own rescue block so a broken reporter doesn't affect the rest.
Duplicate prevention uses an instance variable on the exception
(similar to Rails). Manually-created exceptions get a real backtrace
via re-raise rather than set_backtrace(caller).
Hooked into all existing framework rescue sites: controllers,
fiber wrapper, Cable connections/channels, Redis adapter, deferred
tasks, event subscribers, SSE streams, and telemetry tracers.

Signed-off-by: Digvijay Singh Rawat <hackerearthx1@gmail.com>
@Digvijay-x1 Digvijay-x1 changed the title Add centralized error reporting via Rage::Errors [WIP] Add centralized error reporting via Rage::Errors Apr 14, 2026
@rsamoilov
Copy link
Copy Markdown
Member

Hey @Digvijay-x1 ,

I usually don't review in-progress PRs, so I haven't looked at this one yet. Anything I can help with? Do you want me to give it a look?

@Digvijay-x1
Copy link
Copy Markdown
Contributor Author

Hey @Digvijay-x1 ,

I usually don't review in-progress PRs, so I haven't looked at this one yet. Anything I can help with? Do you want me to give it a look?

Hey @rsamoilov,

Thanks for offering to help :)

Before requesting a review, I wanted to test whether all cases behave as expected. This took a bit longer since I had some college assignments last week.

From my testing so far, the core error reporting API appears to be working well. I set up a small Rage app with Sentry integration and verified that reporter registration, error forwarding, context propagation, duplicate prevention, and backtrace generation all behave correctly.

I’ve tested 5 out of the 9 call sites so far — including unhandled controller exceptions (covering both application.rb and fiber_wrapper.rb), deferred task failures, and direct Rage::Errors.report calls.

The remaining areas (events/subscriber, SSE, Cable, Redis adapter, telemetry) all route through the same Rage::Errors.report method, which is already working as expected.

I think the PR is in a good state for review now. Would appreciate your feedback whenever you get a chance!

@Digvijay-x1 Digvijay-x1 marked this pull request as ready for review April 20, 2026 19:55
@Digvijay-x1 Digvijay-x1 changed the title [WIP] Add centralized error reporting via Rage::Errors Add centralized error reporting via Rage::Errors Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Errors] Centralized error reporting interface

2 participants