| 1 |
// SPDX-License-Identifier: MPL-2.0 |
| 2 |
// (c) Hare authors <https://harelang.org> |
| 3 |
|
| 4 |
// Returned when adding an extension if the path is root, or the final path |
| 5 |
// segment consists entirely of dots. |
| 6 |
export type cant_extend = !void; |
| 7 |
// Returned when a path buffer would have overflowed. |
| 8 |
export type too_long = !void; |
| 9 |
// Returned when [[trimprefix]] receives a prefix that is not present. |
| 10 |
export type not_prefix = !void; |
| 11 |
// Represents an error during a path manipulation |
| 12 |
export type error = !(cant_extend | too_long | not_prefix); |
| 13 |
|
| 14 |
// Convert an [[error]] into a descriptive string. |
| 15 |
export fn strerror(e: error) str = { |
| 16 |
match (e) { |
| 17 |
case cant_extend => |
| 18 |
return "Can't add extension (filename is root or all dots)"; |
| 19 |
case too_long => |
| 20 |
return "Path buffer overflow"; |
| 21 |
case not_prefix => |
| 22 |
return "Prefix not present"; |
| 23 |
}; |
| 24 |
}; |