-
-
Notifications
You must be signed in to change notification settings - Fork 17
Introduce UserException
attribute
#153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
vjik
commented
Aug 17, 2025
Q | A |
---|---|
Is bugfix? | ❌ |
New feature? | ✔️ |
Breaks BC? | ❌ |
Co-authored-by: Aleksei Gagarin <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #153 +/- ##
=========================================
Coverage ? 81.06%
Complexity ? 215
=========================================
Files ? 20
Lines ? 692
Branches ? 0
=========================================
Hits ? 561
Misses ? 131
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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 introduces the UserException
as an attribute that can be used to mark exceptions as user-facing, expanding its functionality beyond just being an exception class. The change allows any exception class to be annotated with #[UserException]
to indicate its messages are safe to display to end users.
- Added
UserException::is()
static method to check if an exception is user-facing - Converted
UserException
to also function as a PHP attribute - Updated templates to use the new
is()
method instead of instanceof checks
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/Exception/UserException.php | Enhanced to work as both exception class and attribute, added static is() method |
templates/production.php | Updated to use UserException::is() instead of instanceof check |
tests/Exception/UserException/UserExceptionTest.php | Added comprehensive tests for the new functionality |
tests/Exception/UserException/NotFoundException.php | Created test exception class using the new attribute |
tests/Factory/ThrowableResponseFactoryTest.php | Code formatting cleanup (method chaining) |
CHANGELOG.md | Added changelog entry for the new feature |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Alexander Makarov <[email protected]>
return true; | ||
} | ||
|
||
$attributes = (new ReflectionClass($throwable))->getAttributes(self::class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can caching affect performance? e.g long running apps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it doesn't make sense in the case of exception handling.