Does this mean you have to know the name of the function calling you that's supposed to handle the error? What if you're a library and don't know that?
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.
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?