37 lines
920 B
Rust
37 lines
920 B
Rust
//
|
|
// Copyright 2023 James Pace
|
|
//
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
//
|
|
// This Source Code Form is "Incompatible With Secondary Licenses", as
|
|
// defined by the Mozilla Public License, v. 2.0.
|
|
//
|
|
use alloc::string::{String, ToString};
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub enum Error {
|
|
Msg(String),
|
|
}
|
|
|
|
impl Error {
|
|
pub fn from_msg(msg: &str) -> Self {
|
|
Error::Msg(msg.to_string())
|
|
}
|
|
}
|
|
|
|
impl core::fmt::Display for Error {
|
|
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
|
match self {
|
|
Error::Msg(msg) => {
|
|
write!(f, "Error manipulating graph: {}", msg)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
impl core::error::Error for Error {}
|
|
|
|
pub type Result<T, E = Error> = core::result::Result<T, E>;
|