mirror of
https://code.blicky.net/yorhel/ncdu.git
synced 2026-01-13 01:08:41 -09:00
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.
This commit is contained in:
parent
3a21dea2cd
commit
5a196125dc
1 changed files with 2 additions and 4 deletions
|
|
@ -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 {
|
||||||
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.
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue