1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
// SPDX-License-Identifier: MPL-2.0
// (c) Hare authors <https://harelang.org>
use encoding::utf8;
use fs;
use io;
use net::ip;
// Returned when an invalid host line was found.
export type invalid = !void;
// All possible errors returned from this module.
export type error = !(io::error | invalid | utf8::invalid | ip::invalid
| fs::error);
// Converts an [[error]] to a human-friendly representation.
export fn strerror(err: error) const str = {
match (err) {
case invalid =>
return "Host file format is invalid";
case utf8::invalid =>
return "File is invalid UTF-8";
case ip::invalid =>
return "IP address is invalid";
case let err: io::error =>
return io::strerror(err);
case let err: fs::error =>
return fs::strerror(err);
};
};
|