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

feat: let nothrow be a filter #758

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

antongolub
Copy link
Contributor

closes #714

(await $`exit 42`.nothrow(42)).exitCode                               // 42
(await $({ nothrow: [42] })`exit 42`).exitCode                        // 42
(await $({ nothrow(code) { return code === 42 } })`exit 42`).exitCode // 42

@antonmedv
Copy link
Collaborator

Do we really want this complication? Not from implementation perspective, but from API perspective.

I think simple boolean flag is much nicer API. And implementing custom filtering logic in catch is trivial.

Unless there is a common use case for such API. I can not see any.

@antongolub
Copy link
Contributor Author

antongolub commented Mar 31, 2024

¯\_(ツ)_/¯

`p.catch` is fine, but try-catch...
try {
  $.sync()
} catch (e) {
 
}

@antonmedv
Copy link
Collaborator

let p = $.sync`cmd`.nothrow()
if (p.exitCode == 1) throw err

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

Successfully merging this pull request may close these issues.

Feature request: nothrow() only for a subset of error codes
2 participants