charly-vm icon indicating copy to clipboard operation
charly-vm copied to clipboard

Try statements for specific exception types

Open KCreate opened this issue 3 years ago • 0 comments

The following syntax should be possible

try {
    foo()
} catch SomeException {
    // catches only exceptions of type SomeException, doesn't provide a binding
} catch OtherException as exc {
    // catches only exceptions of type OtherException, provides a binding (exc)
} catch exc {
    // catches all types of exceptions, provides a binding (exc)
} catch {
    // catches all types of exceptions, doesn't provide a binding
}

Could use the instanceof operation described in #64 to perform a typecheck at the beginning of the exception handler, then dispatch to correct handler.

KCreate avatar Jul 29 '22 01:07 KCreate