1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
use fmt;
use io;
// A syntax error
export type syntax = !(location, str);
// All possible lexer errors
export type error = !(io::error | syntax);
// Returns a human-friendly string for a given error. The result may be
// statically allocated.
export fn strerror(err: error) const str = {
static let buf: [2048]u8 = [0...];
match (err) {
case let err: io::error =>
return io::strerror(err);
case let s: syntax =>
return fmt::bsprintf(buf, "{}:{}:{}: syntax error: {}",
s.0.path, s.0.line, s.0.col, s.1)!;
};
};
|