hare-xdg/format/desktop_entry/error.ha

28 lines
930 B
Hare
Raw Normal View History

2024-10-12 21:51:52 -06:00
// All errors defined in this module.
2024-10-12 21:34:44 -06:00
export type error = !(
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;
2024-10-12 20:12:43 -06:00
// Converts a desktop entry [[error]] into a user-friendly string.
2024-10-12 21:34:44 -06:00
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";
2024-10-12 20:12:43 -06:00
};