-
Notifications
You must be signed in to change notification settings - Fork 46
Clearer exception messages. #84
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
Im done with this PR. |
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.
👍
*/ | ||
public function __construct($message, array $exceptions = []) | ||
{ | ||
$this->exceptions = $exceptions; | ||
|
||
parent::__construct($message, 0, array_shift($exceptions)); | ||
parent::__construct($message); |
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.
this is eating away the chance to see a root cause exception. in general, it could be useful to see where the original problem comes from. but in the situation i agree it would be more confusing than helpful.
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've been back and forth with this. But I believe this is the best solution.
Say that you have 5 different strategies. 4 of them fails (StrategyUnavailable
), The exception message for the first exception will say "Puli factory not found". But your intention was to use "FoobarStrategy". So "Puli" will be confusing.
The new message will be:
Fatal error: Uncaught Http\Discovery\Exception\DiscoveryFailedException: Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors
- Puli Factory is not available
- Foobar strategy is not available
- Something else.
i agree with you. just wanted to point this out so we are aware of it.
|
92972c3
to
b0f7fef
Compare
I added a change log |
Looks good to me |
Relates to mailgun/mailgun-php#222
If discovery fails we get an error like:
Which leads users to think ""wtf is Puli?"..
With this PR we get an exception like this instead. This is more descriptive:
When php-http/message and a PSR7 is installed and I try to rerun I get an exception like: