Remove error foo from module

This commit is contained in:
Matthias Beyer 2015-10-19 17:32:29 +02:00
parent 18ebf8ad83
commit 19ab3d425f
1 changed files with 2 additions and 40 deletions

View File

@ -1,49 +1,11 @@
use runtime::Runtime;
pub struct ModuleError {
shortdesc : String,
longdesc : String,
}
impl ModuleError {
pub fn short(short : String) -> ModuleError {
ModuleError::new(short, "".to_string())
}
pub fn new(short : String, long : String) -> ModuleError {
ModuleError {
shortdesc: short,
longdesc: long,
}
}
pub fn print(&self, rt : &Runtime) {
if self.longdesc.is_empty() {
let s = format!("Error: {}\n\n{}\n\n",
self.shortdesc, self.longdesc);
rt.print(&s)
} else {
let s = format!("Error: {}\n", self.shortdesc);
rt.print(&s)
}
}
pub fn print_short(&self, rt : &Runtime) {
rt.print(&self.shortdesc)
}
pub fn print_long(&self, rt : &Runtime) {
rt.print(&self.longdesc)
}
}
use std::error::Error;
pub trait Module {
fn load(self, &rt : Runtime) -> Self;
fn name(self) -> String;
fn execute(self, &rt : Runtime) -> Option<ModuleError>;
fn execute(&self, &rt : Runtime) -> Option<Error>;
}