LYR-SEM0036
a try block without a catch
A try { … } block statement has no catch clause.
Explanation
A try block exists to catch what its body throws; without a clause it does nothing. There is no finally — code that runs on every way out of a scope is a defer.
Add a catch clause, or drop the try and let the error propagate through the function's throws.
Wrong
class Disk :: [Error] { fn message(): string { return "disk"; } }
fn read(): int throws Disk { throw Disk { }; }
fn main(): void throws Disk {
try { let _ = read(); }
}
Right
class Disk :: [Error] { fn message(): string { return "disk"; } }
fn read(): int throws Disk { throw Disk { }; }
fn main(): void {
try { let _ = read(); }
catch (_: Disk) { }
}