Skip to content

Conversation

@zeitlinger
Copy link
Member

No description provided.

Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors exception handling throughout the codebase to use more specific exception types instead of catching generic Exception, improving code clarity and making the expected failure modes more explicit.

Changes:

  • Narrowed catch blocks from Exception to specific exception types (RuntimeException, IOException, UnsupportedOperationException, ReflectiveOperationException)
  • Added explicit null check for InputStream in PrometheusInstrumentationScope before use
  • Updated exception handling comments to be more descriptive
  • Removed .havingRootCause() assertions in tests to match the simplified exception wrapping behavior

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
JvmNativeMemoryMetrics.java Changed catch block from Exception to RuntimeException and improved comment to clarify what runtime failures are caught
AbstractDropwizardExports.java Changed catch block from Exception to RuntimeException for metric collection errors
CacheMetricsCollector.java Changed catch block from Exception to UnsupportedOperationException to specifically handle unavailable evictionWeight metric
PrometheusInstrumentationScopeTest.java Removed .havingRootCause() assertions as IllegalStateExceptions now propagate directly without wrapping
PrometheusInstrumentationScope.java Changed catch block to IOException only, added explicit null check for InputStream, and added required imports
OtelAutoConfig.java Changed catch block from Exception to ReflectiveOperationException for reflection operations
HttpExchangeAdapter.java Changed catch block from Exception to IOException for error response writing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zeitlinger zeitlinger requested a review from jaydeluca February 3, 2026 13:47
@zeitlinger zeitlinger merged commit a865c65 into main Feb 3, 2026
49 checks passed
@zeitlinger zeitlinger deleted the exception-handling branch February 3, 2026 14:24
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.

3 participants