File: error.ha

package info (click to toggle)
hare 0.25.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,948 kB
  • sloc: asm: 1,264; makefile: 123; sh: 114; lisp: 101
file content (24 lines) | stat: -rw-r--r-- 819 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// SPDX-License-Identifier: MPL-2.0
// (c) Hare authors <https://harelang.org>

// Returned when adding an extension if the path is root, or the final path
// segment consists entirely of dots.
export type cant_extend = !void;
// Returned when a path buffer would have overflowed.
export type too_long = !void;
// Returned when [[trimprefix]] receives a prefix that is not present.
export type not_prefix = !void;
// Represents an error during a path manipulation
export type error = !(cant_extend | too_long | not_prefix);

// Convert an [[error]] into a descriptive string.
export fn strerror(e: error) str = {
	match (e) {
	case cant_extend =>
		return "Can't add extension (filename is root or all dots)";
	case too_long =>
		return "Path buffer overflow";
	case not_prefix =>
		return "Prefix not present";
	};
};