-
-
Notifications
You must be signed in to change notification settings - Fork 315
Description
I noticed that this pattern fails with Exception: wrong type of 1'th argument: wrong type: need string, got exception
:
try {
/usr/bin/false
} except e {
fail e
}
It seems to me it should be possible to re-throw an exception. Yes, you can do fail (to-string $e)
but that will lose information if and when exception objects have attributes other than cause
. It also violates the DRY principal (don't repeat yourself).
On a closely related note we'll probably want fail
to accept options to set the hypothetical attributes that seem likely to be added in the future. As a stepping stone fail
it might be useful to augment it accept an optional cause
option that can be used instead of the current string argument. Either that or the current mandatory argument could be used but not both at the same time.
Activity
krader1961 commentedon Apr 9, 2020
I see that @hanche proposed re-throwing an exception in this comment.
[-]`fail` should allow an exception object in addition to a string[/-][+]`fail` should support rethrowing an exception object[/+]