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

fail should support rethrowing an exception object #941

Closed
krader1961 opened this issue Mar 18, 2020 · 1 comment
Closed

fail should support rethrowing an exception object #941

krader1961 opened this issue Mar 18, 2020 · 1 comment
Milestone

Comments

@krader1961
Copy link
Contributor

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.

@krader1961
Copy link
Contributor Author

I see that @hanche proposed re-throwing an exception in this comment.

@xiaq xiaq changed the title fail should allow an exception object in addition to a string fail should support rethrowing an exception object May 3, 2020
@xiaq xiaq added the A:Language label May 3, 2020
@xiaq xiaq modified the milestones: 0.15, 0.14 May 3, 2020
@xiaq xiaq closed this as completed in 92cb80d May 4, 2020
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

2 participants