File: error.ha

package info (click to toggle)
hare-update 0.26.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,044 kB
  • sloc: makefile: 37; sh: 14
file content (24 lines) | stat: -rw-r--r-- 569 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>

use common;
use fmt;
use vNEXT::lex;

// All possible error types.
export type error = !common::error;

// Convert an error into a human-friendly string. The result may be statically
// allocated.
export fn strerror(err: error) const str = common::strerror(err: common::error);

fn syntaxerr(
	loc: common::location,
	fmt: str,
	args: fmt::field...
) common::error = {
	static let buf: [4096]u8 = [0...];
	let why = fmt::bsprintf(buf, fmt, args...)!;
	return lex::syntaxerr(loc, why);
};