37 lines
1.2 KiB
Hare
37 lines
1.2 KiB
Hare
use encoding::utf8;
|
|
use io;
|
|
|
|
// Any error that may occur during parsing.
|
|
export type error = !(syntaxerr | io::error | utf8::invalid);
|
|
|
|
// All syntax errors defined in this module.
|
|
export type syntaxerr = !(
|
|
invalid_group_header |
|
|
invalid_entry |
|
|
invalid_ascii |
|
|
invalid_escape);
|
|
|
|
// Returned when a malformed group header is encountered while parsing.
|
|
export type invalid_group_header = !void;
|
|
|
|
// Returned when a malformed entry is encountered while parsing.
|
|
export type invalid_entry = !void;
|
|
|
|
// Returned when ASCII text was expected while parsing, but something else was
|
|
// given.
|
|
export type invalid_ascii = !void;
|
|
|
|
// Returned when an invalid escape sequence was enctountered while parsing.
|
|
export type invalid_escape = !void;
|
|
|
|
// Returns a user-friendly representation of [[error]]. The result may be
|
|
// statically allocated.
|
|
export fn strerror(err: error) str = match (err) {
|
|
case invalid_group_header => yield "invalid group header";
|
|
case invalid_entry => yield "invalid entry";
|
|
case invalid_ascii => yield "invalid ascii";
|
|
case invalid_escape => yield "invalid escape";
|
|
case let err: io::error => yield io::strerror(err);
|
|
case let err: utf8::invalid => yield utf8::strerror(err);
|
|
};
|