Make error an enum.

This commit is contained in:
jimmy committed 2026-07-03 14:31:45 -04:00
1 parent 736798e65a
commit c9a5b0c526
2 files changed
+30 -26

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
//
// 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>;