Skip to content

Add exception handling for data retrieval in chart widgets - #26

Merged
roble merged 7 commits into
mainfrom
dev-v2
Jun 11, 2026
Merged

Add exception handling for data retrieval in chart widgets#26
roble merged 7 commits into
mainfrom
dev-v2

Conversation

@roble

@roble roble commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

This pull request introduces improved error handling for chart widgets and minor code cleanups in test files. The most significant updates are the addition of try-catch blocks to prevent unhandled exceptions in dashboard widgets, and minor refactoring to use the global app() helper in tests for consistency.

Error handling improvements in chart widgets:

  • Added try-catch blocks around database queries in getData() for ConversionChartWidget, RevenueChartWidget, and SubscriptionsChartWidget, ensuring that exceptions are caught and reported rather than causing widget failures. [1] [2] [3] [4] [5] [6]

Test code refactoring:

  • Updated test setup methods to use the global app() helper instead of $this->app, improving code consistency in multiple test files. [1] [2] [3] [4] [5] [6]
  • Cleaned up DatabaseSeederTest by removing a redundant assertion and explicitly calling $this->expectNotToPerformAssertions().

Copilot AI review requested due to automatic review settings June 7, 2026 15:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 improves resilience of Filament dashboard chart widgets by wrapping their data queries/aggregation loops in try/catch blocks so widget rendering won’t hard-fail on query-time exceptions. It also performs small test cleanups to use the global app() helper consistently and removes a redundant assertion from a seeder test.

Changes:

  • Added try/catch around chart widget query + bucketing logic in ConversionChartWidget, RevenueChartWidget, and SubscriptionsChartWidget.
  • Refactored several feature tests to use app() instead of $this->app for container access.
  • Simplified DatabaseSeederTest to explicitly perform no assertions while still executing the seeder.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Filament/Widgets/SubscriptionsChartWidget.php Wrap subscription aggregation query and bucketing loop with exception handling.
src/Filament/Widgets/RevenueChartWidget.php Wrap revenue aggregation query and bucketing loop with exception handling.
src/Filament/Widgets/ConversionChartWidget.php Wrap conversion aggregation query and bucketing loop with exception handling.
tests/Feature/WebhookIdempotencyTest.php Use app() helper for container binding and service resolution in setup.
tests/Feature/SubscriptionResumeTest.php Use app() helper for container binding in setup.
tests/Feature/SubscriptionCancelTest.php Use app() helper for container binding in setup.
tests/Feature/CheckoutSessionValidationTest.php Use app() helper for container binding in setup.
tests/Feature/CheckoutControllerTest.php Use app() helper for container binding in setup.
tests/Feature/BillingServiceTest.php Use app() helper for container binding and service resolution in setup.
tests/Feature/DatabaseSeederTest.php Remove redundant assertion and mark test as not performing assertions while still seeding.

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

Comment thread src/Filament/Widgets/SubscriptionsChartWidget.php Outdated
Comment thread src/Filament/Widgets/RevenueChartWidget.php Outdated
Comment thread src/Filament/Widgets/ConversionChartWidget.php Outdated
@roble
roble merged commit 7797fb2 into main Jun 11, 2026
3 checks passed
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.

2 participants