I have some code that handled errors from a function call inside a loop
const stuff = call_something() catch |err| switch (err) {
// handle errors
continue;
}
// handle non-error cases
I then wanted to add another code path outside the loop that would need to handle the same error and non error conditions so I refactored to
const stuff_or_error call_something;
handle_stuff_or_error(stuff_or_error);
But I can't figure out the function signature. Something like:
fn handle_stuff_or_error(anyerror!thetype) void {
I tried a few things. My actual code is more complicated of course. In the case of anyerror here is the compiler error output my actual code produces. I don't know how to use this info to find what to replade anyerror with:
src/main.zig:85:128: error: expected type 'anyerror!fs.Dir.Entry', found '@typeInfo(@typeInfo(@TypeOf(fs.Dir.Walker.next)).Fn.return_type.?).ErrorUnion.error_set!?fs.Dir.Walker.Entry'