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
Branches
Tags
No related merge requests found
...@@ -48,7 +48,7 @@ pub fn oom() void { ...@@ -48,7 +48,7 @@ pub fn oom() void {
init(); 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) // (Would be nicer if Zig just exposed errno so I could call strerror() directly)
pub fn errorString(e: anyerror) [:0]const u8 { pub fn errorString(e: anyerror) [:0]const u8 {
return switch (e) { return switch (e) {
...@@ -70,9 +70,7 @@ pub fn errorString(e: anyerror) [:0]const u8 { ...@@ -70,9 +70,7 @@ pub fn errorString(e: anyerror) [:0]const u8 {
error.ReadOnlyFilesystem => "Read-only filesystem", error.ReadOnlyFilesystem => "Read-only filesystem",
error.SymlinkLoop => "Symlink loop", error.SymlinkLoop => "Symlink loop",
error.SystemFdQuotaExceeded => "System file descriptor limit exceeded", error.SystemFdQuotaExceeded => "System file descriptor limit exceeded",
else => "Unknown error", // rather useless :( else => @bitCast([:0]const u8, @errorName(e)), // XXX: The bitCast can be removed after a Zig >0.8 release.
// ^ TODO: remove that one and accept only a restricted error set for
// compile-time exhaustiveness checks.
}; };
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment