37 lines
736 B
Rust
37 lines
736 B
Rust
use std::convert::From;
|
|
use std::io::Error as IOError;
|
|
use std::error::Error as STDError;
|
|
|
|
use logger::LogLevel;
|
|
|
|
pub struct Error {
|
|
description: String,
|
|
severity: LogLevel,
|
|
}
|
|
|
|
impl Error {
|
|
pub fn new<T: Into<String>>(severity: LogLevel, description: T) -> Error {
|
|
Error {
|
|
severity,
|
|
description: description.into(),
|
|
}
|
|
}
|
|
|
|
pub fn description(&self) -> String {
|
|
self.description.clone()
|
|
}
|
|
|
|
pub fn severity(&self) -> LogLevel {
|
|
self.severity.clone()
|
|
}
|
|
}
|
|
|
|
impl From<IOError> for Error {
|
|
fn from(err: IOError) -> Error {
|
|
Error {
|
|
description: err.description().to_owned(),
|
|
severity: LogLevel::SEVERE,
|
|
}
|
|
}
|
|
}
|