Skip to content
Snippets Groups Projects
Commit 5a196125 authored by Yorhel's avatar Yorhel
Browse files

Use @errorName() fallback in ui.errorString()

Sticking to "compiletime-known" error types will essentially just bring
in *every* possible error anyway, so might as well take advantage of
@errorName.
parent 3a21dea2
No related branches found
No related tags found
No related merge requests found
......@@ -48,7 +48,7 @@ pub fn oom() void {
init();
}
// Lazy strerror() for Zig file I/O, not complete.
// Dumb strerror() alternative for Zig file I/O, not complete.
// (Would be nicer if Zig just exposed errno so I could call strerror() directly)
pub fn errorString(e: anyerror) [:0]const u8 {
return switch (e) {
......@@ -70,9 +70,7 @@ pub fn errorString(e: anyerror) [:0]const u8 {
error.ReadOnlyFilesystem => "Read-only filesystem",
error.SymlinkLoop => "Symlink loop",
error.SystemFdQuotaExceeded => "System file descriptor limit exceeded",
else => "Unknown error", // rather useless :(
// ^ TODO: remove that one and accept only a restricted error set for
// compile-time exhaustiveness checks.
else => @bitCast([:0]const u8, @errorName(e)), // XXX: The bitCast can be removed after a Zig >0.8 release.
};
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment