diff options
Diffstat (limited to 'src/error.rs')
| -rw-r--r-- | src/error.rs | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/src/error.rs b/src/error.rs index 7483f00..3c46097 100644 --- a/src/error.rs +++ b/src/error.rs @@ -5,8 +5,6 @@ use axum::{ response::{IntoResponse, Response}, }; -use crate::id::Id as BaseId; - // I'm making an effort to avoid `anyhow` here, as that crate is _enormously_ // complex (though very usable). We don't need to be overly careful about // allocations on errors in this app, so this is fine for most "general @@ -45,25 +43,14 @@ impl IntoResponse for Internal { } } -// Transient identifier for an InternalError. Prefixed with `E`. -#[derive(Debug)] -pub struct Id(BaseId); - -impl From<BaseId> for Id { - fn from(id: BaseId) -> Self { - Self(id) - } -} +pub type Id = crate::id::Id<InternalError>; -impl Id { - pub fn generate() -> Self { - BaseId::generate("E") - } -} +#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub struct InternalError; -impl fmt::Display for Id { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.0.fmt(f) +impl crate::id::Prefix for InternalError { + fn prefix(&self) -> &'static str { + "E" } } |
