Search code examples
zig

Is it possible to convert a std.builtin.TypeInfo.Error back to its error value?


The struct std.builtin.TypeInfo.Error only contains a name field. And since no @nameToError function exists, I don't see a way to convert this to it's error value.

In version 0.6 of zig that struct has a value field, which holds the number to instantiate the error via @intToError. But that no longer exists.

Am I overseeing something?


Solution

  • I've got the answer via the zig issue tracker.

    @field(MyErrorSet, "errorName")
    

    can be used to get the error value.