Skip to content

docs(agents): Forbid introducing new catch Throwable - #5944

Merged
runningcode merged 2 commits into
mainfrom
no/docs-agents-no-new-catch-throwable
Aug 13, 2026
Merged

docs(agents): Forbid introducing new catch Throwable#5944
runningcode merged 2 commits into
mainfrom
no/docs-agents-no-new-catch-throwable

Conversation

@runningcode

@runningcode runningcode commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

📜 Description

Adds an Exception Handling section to AGENTS.md to use the new ExceptionUtils.rethrowIfFatal. Please feel free to debate the proposal!

💡 Motivation and Context

Writing the rule down in AGENTS.md stops the pattern from spreading into new code without touching any of the existing call sites.

💚 How did you test it?

Documentation-only change; no code paths affected. Verified that ExceptionUtils.rethrowIfFatal exists and behaves as the section describes.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

#skip-changelog

Add an "Exception Handling" section to AGENTS.md telling agents to catch
the narrowest exception type the guarded code can throw, and to never add
a new catch (Throwable). The repo already has ~355 such catches in main
sources; they are legacy and should not be read as a precedent.

A broad catch swallows OutOfMemoryError, StackOverflowError, ThreadDeath
and LinkageError, and hides bugs in our own code behind a log line. The
"never crash the host app" requirement is what usually motivates these
catches, so the section points at ExceptionUtils.rethrowIfFatal as the
way to satisfy it, and calls out the two cases that need care: probing an
optional compileOnly dependency via a LinkageError subclass, and not
swallowing InterruptedException.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@sentry

sentry Bot commented Aug 12, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.52.0 (1) release

⚙️ sentry-android Build Distribution Settings

The LinkageError and InterruptedException notes were detail the core rule
does not need.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@runningcode
runningcode marked this pull request as ready for review August 12, 2026 14:36
@runningcode runningcode added the sanity-check PR needs a lightweight review for obvious issues label Aug 12, 2026
Comment thread AGENTS.md
@runningcode
runningcode merged commit 43777a5 into main Aug 13, 2026
74 checks passed
@runningcode
runningcode deleted the no/docs-agents-no-new-catch-throwable branch August 13, 2026 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sanity-check PR needs a lightweight review for obvious issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants