Skip to content
Snippets Groups Projects
Verified Commit 3943b02d authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

chore: greatly improved error handling in state

This approach avoids many of the possible panics.
parent 06f3dd0e
No related branches found
No related tags found
No related merge requests found
Pipeline #4780 passed
......@@ -5,7 +5,11 @@
//! This module contains the [`Error`] enum, which is used to represent
//! errors that can occur within Boytacean domain.
use std::fmt::{self, Display, Formatter};
use std::{
fmt::{self, Display, Formatter},
io,
string::FromUtf8Error,
};
/// Top level enum for error handling within Boytacean.
///
......@@ -37,3 +41,15 @@ impl Display for Error {
write!(f, "{}", self.description())
}
}
impl From<io::Error> for Error {
fn from(_error: io::Error) -> Self {
Error::CustomError(String::from("IO error"))
}
}
impl From<FromUtf8Error> for Error {
fn from(_error: FromUtf8Error) -> Self {
Error::CustomError(String::from("From UTF8 error"))
}
}
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment