prewk/result

Change doc comment to throw ResultException

cundd opened this issue · 4 comments

cundd commented

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 commented

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

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 commented

Ah, yeah. Of course. That makes sense.

Thank you for the answer.

prewk commented

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.