Added thiserror derives

This commit is contained in:
Zachary Levy
2026-04-12 12:01:34 -07:00
parent d0b792be0e
commit 2a0d9e0097
2 changed files with 12 additions and 4 deletions
+10 -4
View File
@@ -1,9 +1,13 @@
use thiserror::Error;
/// Indicates the transducer value is known to be impossible.
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Error)]
#[error("invalid value")]
pub struct InvalidValue;
/// Indicates that the encoded data is not valid for the type.
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Error)]
#[error("invalid encoding")]
pub struct InvalidEncoding;
/// An error that it is likely impossible to recover from. This error should only be created in
/// situations where attempts to recover have already been attempted and have failed. Error handling
@@ -12,11 +16,13 @@ pub struct InvalidEncoding;
///
/// In many systems there can be a single function for handling any critical error as a critical
/// error always means everything needs to be stopped.
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
#[derive(Copy, Clone, Eq, PartialEq, Debug, Error)]
pub enum CriticalError {
/// Critical communication failed and retries are either impossible or also failed.
#[error("critical communication failure")]
Communication,
InvalidValue(InvalidValue),
#[error(transparent)]
InvalidValue(#[from] InvalidValue),
}
/// A state of this type may mean the program has encountered an error that prevents it from continuing to run