33 lines
796 B
MoonBit
33 lines
796 B
MoonBit
///|
|
|
/// Single error type shared by all mnix packages. Every failure is loud:
|
|
/// there are no silent fallbacks anywhere in the code base.
|
|
pub(all) suberror NixError {
|
|
Parse(String)
|
|
Verify(String)
|
|
Network(String)
|
|
Io(String)
|
|
Unsupported(String)
|
|
}
|
|
|
|
///|
|
|
pub impl Show for NixError with fn output(self, logger) {
|
|
match self {
|
|
Parse(m) => logger.write_string("parse error: \{m}")
|
|
Verify(m) => logger.write_string("verification failed: \{m}")
|
|
Network(m) => logger.write_string("network error: \{m}")
|
|
Io(m) => logger.write_string("I/O error: \{m}")
|
|
Unsupported(m) => logger.write_string("unsupported: \{m}")
|
|
}
|
|
}
|
|
|
|
///|
|
|
/// Test helper: true if `f` raises.
|
|
pub fn[T] raises(f : () -> T raise) -> Bool {
|
|
try {
|
|
ignore(f())
|
|
false
|
|
} catch {
|
|
_ => true
|
|
}
|
|
}
|