There was some discussion about this in the Goose discord a few days ago.
One idea that came up was this: you could define a particuda function name as the "landing pad" for handling particular error kinds. Then you "wrap" calls to the library in a function with this name. Here's a part from a larger worked example:
fn catch_io<F: fn()>() -> IoError {
F();
return IoError{ message: "", ok: true }
}
let err = catch_io() { c(); };
https://gist.github.com/bkietz/9bf510299ab62bb4c7f7d2db6eff0...Mind you, this was just discussion, no experience with how well this would work in practice.
Wouldn't it be cooler if you could `return IoError{} from ^` and it would find the closest function in the call stack that can return an IoError?
Even better, you could give it some syntactic sugar like `throw IoError{}`? ;)
P.S. I think the `IoError { message, ok }` type is suspiciously close to `Result<(), String>`.. And if you want to return a value in the success case too it'll become even closer. Perhaps it's best to lean into that and find the calling function that can return an IoError as one of the possible values?