hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

errors.ha (831B)


      1 // SPDX-License-Identifier: MPL-2.0
      2 // (c) Hare authors <https://harelang.org>
      3 
      4 use errors;
      5 use encoding::utf8;
      6 use io;
      7 use net::ip;
      8 
      9 // The resolv.conf file is not well-formatted.
     10 export type invalid = !void;
     11 
     12 // Any error which can be raised by the resolv.conf parser.
     13 export type error = !(errors::error | io::error | utf8::invalid | ip::invalid | invalid);
     14 
     15 // Converts an [[error]] into a human-friendly representation.
     16 export fn strerror(err: error) const str = {
     17 	match (err) {
     18 	case invalid =>
     19 		return "resolv.conf is not well-formatted";
     20 	case let err: errors::error =>
     21 		return errors::strerror(err);
     22 	case let err: io::error =>
     23 		return io::strerror(err);
     24 	case let err: ip::invalid =>
     25 		return "Invalid IP address in /etc/resolv.conf";
     26 	case utf8::invalid =>
     27 		return "resolv.conf contains invalid UTF-8 data";
     28 	};
     29 };