-
Notifications
You must be signed in to change notification settings - Fork 3
Errors from Symfony's PropertyAccessor now result in Purgatory's PropertyNotAccessibleException #110
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
base: 2.x
Are you sure you want to change the base?
Errors from Symfony's PropertyAccessor now result in Purgatory's PropertyNotAccessibleException #110
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 1.x #110 +/- ##
============================================
+ Coverage 96.97% 97.13% +0.16%
- Complexity 491 495 +4
============================================
Files 62 62
Lines 1454 1466 +12
============================================
+ Hits 1410 1424 +14
+ Misses 44 42 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| } catch (\InvalidArgumentException|AccessException|UnexpectedTypeException) { | ||
| throw new PropertyNotAccessibleException( | ||
| \is_array($objectOrArray) ? 'array' : $objectOrArray::class, | ||
| (string) $propertyPath, | ||
| ); |
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.
we should probably add previous throwable to PropertyNotAccessibleException so we don't lose error context from property accessor
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.
Added in 7af442d
| $this->expectException(PropertyNotAccessibleException::class); | ||
| $this->expectExceptionMessage( | ||
| \sprintf( | ||
| 'Unable to create a getter for property "%s::%s".', |
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.
not sure about this message, it fits the context it was used for previously, but i don't think is good for errors with property accessor.
maybe we should change the message? @HypeMC
When Symfony's
PropertyAccessorfails to get a property value, whether due to an incorrect argument provided to the method, a non-existent property, or a property with insufficient visibility, one of exceptions will be thrown:InvalidArgumentException,AccessException,UnexpectedTypeExceptionSince Symfony's
PropertyAccessoris used by many other bundles, and often in projects codebase directly, seeing this exception in logs doesn't immediately indicate that error occurred in Purgatory.To improve visibility and observability when these errors occur, we are re-throwing the PropertyAccessor's exception as
PropertyNotAccessibleExceptionwhich is specific to the Purgatory bundle.