format::desktop_entry: Add new errors

This commit is contained in:
Sasha Koshka 2024-10-21 11:38:50 -04:00
parent f401ad26df
commit 776185e574

View File

@ -9,7 +9,10 @@ export type syntaxerr = !(
invalid_group_header | invalid_group_header |
invalid_entry | invalid_entry |
invalid_ascii | invalid_ascii |
invalid_escape); invalid_escape |
invalid_boolean |
invalid_numeric |
expected_single);
// Returned when a malformed group header is encountered while parsing. // Returned when a malformed group header is encountered while parsing.
export type invalid_group_header = !void; export type invalid_group_header = !void;
@ -24,6 +27,18 @@ export type invalid_ascii = !void;
// Returned when an invalid escape sequence was enctountered while parsing. // Returned when an invalid escape sequence was enctountered while parsing.
export type invalid_escape = !void; export type invalid_escape = !void;
// Returned when a boolean value was expected while parsing, but something else
// was given.
export type invalid_boolean = !void;
// Returned when a numeric value was expected while parsing, but something else
// was given.
export type invalid_numeric = !void;
// Returned when a singular value was expected while parsing, but multiple
// values were given.
export type expected_single = !void;
// Returns a user-friendly representation of [[error]]. The result may be // Returns a user-friendly representation of [[error]]. The result may be
// statically allocated. // statically allocated.
export fn strerror(err: error) str = match (err) { export fn strerror(err: error) str = match (err) {
@ -31,6 +46,9 @@ case invalid_group_header => yield "invalid group header";
case invalid_entry => yield "invalid entry"; case invalid_entry => yield "invalid entry";
case invalid_ascii => yield "invalid ascii"; case invalid_ascii => yield "invalid ascii";
case invalid_escape => yield "invalid escape"; case invalid_escape => yield "invalid escape";
case invalid_boolean => yield "invalid boolean";
case invalid_numeric => yield "invalid numeric";
case expected_single => yield "expected single";
case let err: io::error => yield io::strerror(err); case let err: io::error => yield io::strerror(err);
case let err: utf8::invalid => yield utf8::strerror(err); case let err: utf8::invalid => yield utf8::strerror(err);
}; };