Skip to content
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

Change doc comment to throw ResultException #8

Closed
cundd opened this issue Feb 12, 2020 · 4 comments
Closed

Change doc comment to throw ResultException #8

cundd opened this issue Feb 12, 2020 · 4 comments

Comments

@cundd
Copy link

cundd commented Feb 12, 2020

unwrap() appears to throw a ResultException on error, but the doc comment mentions \Exception (see https://github.com/prewk/result/blob/master/src/Result.php#L164).

Is it possible to change the doc comment?

In the IDE PhpStorm this would be handy to add ResultException to the list of "Unchecked Exceptions".

@cundd
Copy link
Author

cundd commented Feb 12, 2020

Btw: Great library. We now only need the ?-operator 😄

@andrew-demb
Copy link
Contributor

I thought so too, while improve phpdocs.
But Err class support pass in constructor exception and throw this in unwrap stop me from it.

See:

if ($this->err instanceof Exception) {

@cundd
Copy link
Author

cundd commented Feb 12, 2020

Ah, yeah. Of course. That makes sense.

Thank you for the answer.

@cundd cundd closed this as completed Feb 12, 2020
@prewk
Copy link
Owner

prewk commented Feb 13, 2020

Ah, yeah I think my reasoning was that "it throws something that is or extends \Exception". By default it's ResultException but I've almost always used it with custom exceptions to make things grouped nicely at Sentry etc.

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

No branches or pull requests

3 participants