Add: impl ImagError for ModuleError
This commit is contained in:
parent
e9b122f612
commit
7b1f9cfbac
1 changed files with 31 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
||||||
use runtime::Runtime;
|
use runtime::Runtime;
|
||||||
|
use error::ImagError;
|
||||||
use error::ImagErrorBase;
|
use error::ImagErrorBase;
|
||||||
|
|
||||||
pub struct ModuleError {
|
pub struct ModuleError {
|
||||||
|
@ -24,6 +25,36 @@ impl ModuleError {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> ImagError<'a> for ModuleError {
|
||||||
|
fn print(&self, rt: &Runtime) {
|
||||||
|
if self.base.longdesc.is_empty() {
|
||||||
|
let s = format!("{}: {}\n\n{}\n\n",
|
||||||
|
self.module_name,
|
||||||
|
self.base.shortdesc,
|
||||||
|
self.base.longdesc);
|
||||||
|
rt.print(&s)
|
||||||
|
} else {
|
||||||
|
let s = format!("{}: {}\n",
|
||||||
|
self.module_name,
|
||||||
|
self.base.shortdesc);
|
||||||
|
rt.print(&s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn print_short(&self, rt : &Runtime) {
|
||||||
|
let s = format!("{}: {}\n", self.module_name, self.base.shortdesc);
|
||||||
|
rt.print(&s)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn print_long(&self, rt : &Runtime) {
|
||||||
|
let s = format!("{}: {}\n\n{}\n\n",
|
||||||
|
self.module_name,
|
||||||
|
self.base.shortdesc,
|
||||||
|
self.base.longdesc);
|
||||||
|
rt.print(&s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub trait Module {
|
pub trait Module {
|
||||||
|
|
||||||
fn new() -> Self;
|
fn new() -> Self;
|
||||||
|
|
Loading…
Reference in a new issue