Provide `nocatch` keyword
LadyCailin opened this issue ยท 4 comments
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
}
This is a valid use-case, but why create a new keyword for this? I would propose a different syntax instead:
try {
_codeThatThrowsAnException();
}
I'd rather it be explicit. This could be an accidental omission, whereas a separate nocatch
block is very explicit.
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.
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.