Is it possible to make early exit in do-try-catch block? (Like `guard`)

Yeah, the solution for this is to require a all errors to be caught with catch and not allow unhandled errors to flow down to the else clause.

This would be a source-breaking change, if you're already in a context that can handle errors.

EDIT: which is not automatically to say that it can't be done, but that it should be addressed directly if you decide to propose it.

I wasn't thinking about code that is already in a context that can handle errors. It would be fine to make the catch clause optional in when thrown errors are already able to exit the scope.

1 Like