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

Provide nocatch keyword #1334

Open
LadyCailin opened this issue Nov 28, 2022 · 4 comments
Open

Provide nocatch keyword #1334

LadyCailin opened this issue Nov 28, 2022 · 4 comments
Labels
feature request New functionality that doesn't exist yet good first issue Wanna take a stab at contributing? Try this one! Should be easier than most.

Comments

@LadyCailin
Copy link
Member

A nocatch block is a block which may throw an exception, which is ignored (except if scream-errors is on.)

nocatch {
    _codeThatThrowsAnException();
}

is compiled to

try {
    _codeThatThrowsAnException();
} catch(Exception @ex) {
    // Ignored
}
@LadyCailin LadyCailin added feature request New functionality that doesn't exist yet good first issue Wanna take a stab at contributing? Try this one! Should be easier than most. labels Nov 28, 2022
@Pieter12345
Copy link
Contributor

This is a valid use-case, but why create a new keyword for this? I would propose a different syntax instead:

try {
    _codeThatThrowsAnException();
}

@LadyCailin
Copy link
Member Author

I'd rather it be explicit. This could be an accidental omission, whereas a separate nocatch block is very explicit.

@lukecfairchild
Copy link
Contributor

lukecfairchild commented Jan 14, 2023

I am with Pieter on this one. If someone accidentally leaves off catch that's their own fault. Personally it makes a lot of sense to me to just make the catch part optional.

@PseudoKnight
Copy link
Contributor

If we added this new block keyword (and it wasn't try), I think something along the lines of catchall, ignore, or suppress make more sense to me than nocatch.

However, most cases where I use try(function()) I do not require support for multiple statements, and places where I would need multiple statements it makes sense to just use the normal catch(Exception @ignore){}. So a single line keyword format would be nicer for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New functionality that doesn't exist yet good first issue Wanna take a stab at contributing? Try this one! Should be easier than most.
Projects
None yet
Development

No branches or pull requests

4 participants