mirror of
https://github.com/bdwgc/bdwgc-rust.git
synced 2026-08-22 12:16:24 -06:00
28 lines
483 B
Rust
28 lines
483 B
Rust
use std::{
|
|
error,
|
|
fmt::{self, Display, Formatter},
|
|
};
|
|
|
|
#[derive(Debug)]
|
|
pub struct Error {
|
|
description: &'static str,
|
|
}
|
|
|
|
impl Error {
|
|
pub fn new(description: &'static str) -> Error {
|
|
Error { description }
|
|
}
|
|
}
|
|
|
|
impl Display for Error {
|
|
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
|
|
write!(formatter, "{}", self.description)
|
|
}
|
|
}
|
|
|
|
impl error::Error for Error {
|
|
fn description(&self) -> &str {
|
|
self.description
|
|
}
|
|
}
|