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 allow an exception object in addition to a string #941

Open
krader1961 opened this issue Mar 18, 2020 · 0 comments
Open

`fail` should allow an exception object in addition to a string #941

krader1961 opened this issue Mar 18, 2020 · 0 comments

Comments

@krader1961
Copy link
Contributor

@krader1961 krader1961 commented Mar 18, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.