bunpen: errors::ext::check: supoort errors::error

This commit is contained in:
2024-09-06 23:13:21 +00:00
parent b6d8aa614c
commit 9814cb5ad7

View File

@@ -1,21 +1,23 @@
// vim: set shiftwidth=2 : // vim: set shiftwidth=2 :
use io; use errors;
use fmt; use fmt;
use fs; use fs;
use io;
use log; use log;
use os; use os;
use os::exec; use os::exec;
use path; use path;
use rt; use rt;
export type error = (io::error | fs::error | os::exec::error | path::error | rt::errno); export type error = (errors::error | fs::error | io::error | os::exec::error | path::error | rt::errno);
// stringify an error. return value is statically allocated, no need to free. // stringify an error. return value is statically allocated, no need to free.
export fn maybe_strerror(what: (void | ...error)) (void | str) = { export fn maybe_strerror(what: (void | ...error)) (void | str) = {
let errorbuf: [4096]u8 = [0...]; let errorbuf: [4096]u8 = [0...];
return match (what) { return match (what) {
case let e: io::error => yield io::strerror(e); case let e: errors::error => yield errors::strerror(e);
case let e: fs::error => yield fs::strerror(e); case let e: fs::error => yield fs::strerror(e);
case let e: io::error => yield io::strerror(e);
case let e: os::exec::error => yield os::exec::strerror(e); case let e: os::exec::error => yield os::exec::strerror(e);
case let e: path::error => yield path::strerror(e); case let e: path::error => yield path::strerror(e);
case let e: rt::errno => case let e: rt::errno =>