#avoid error handling with empty error{}

1 messages · Page 1 of 1 (latest)

gray island
#

Is it possible to not use try or catch unreachable if the error set is known to be error{}? It seems like that should be equivalent to just not having an error set.

This is kind of silly if all the code is hand-written, since you can just remove the error{}!, but there are types generic over the error set, and it might be that some uses do not generate any errors, thus obviating the need for error handling.

coral jungle
#

i believe theres a proposal to allow ignoring empty error sets but atm no

#

if it helps you can use still try on it even in a function that cant error

merry shoal
#

I encountered error{}!T return types in a few generic contexts...
use ... catch |err| switch (err) {} to unwrap the err case.

gray island