chore: move RepositoryError into dedicated file

This commit is contained in:
Jon Seager 2026-02-02 12:57:15 +00:00
parent ab9d4bfa13
commit 6611643424
No known key found for this signature in database
2 changed files with 25 additions and 24 deletions

23
src/domain/errors.rs Normal file
View file

@ -0,0 +1,23 @@
use std::fmt::Display;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum RepositoryError {
#[error("entity not found")]
NotFound,
#[error("conflict: {0}")]
Conflict(String),
#[error("unexpected data store error: {0}")]
Unexpected(String),
}
impl RepositoryError {
pub fn conflict<T: Display>(message: T) -> Self {
Self::Conflict(message.to_string())
}
pub fn unexpected<T: Display>(message: T) -> Self {
Self::Unexpected(message.to_string())
}
}

View file

@ -1,4 +1,5 @@
pub mod bags; pub mod bags;
pub mod errors;
pub mod ids; pub mod ids;
pub mod listing; pub mod listing;
pub mod repositories; pub mod repositories;
@ -8,28 +9,5 @@ pub mod sessions;
pub mod timeline; pub mod timeline;
pub mod tokens; pub mod tokens;
pub mod users; pub mod users;
use std::fmt::Display;
use thiserror::Error; pub use errors::RepositoryError;
// TODO: This should probably be in a file named errors.rs
// so that it's domain::errors::RepositoryError.
#[derive(Debug, Error)]
pub enum RepositoryError {
#[error("entity not found")]
NotFound,
#[error("conflict: {0}")]
Conflict(String),
#[error("unexpected data store error: {0}")]
Unexpected(String),
}
impl RepositoryError {
pub fn conflict<T: Display>(message: T) -> Self {
Self::Conflict(message.to_string())
}
pub fn unexpected<T: Display>(message: T) -> Self {
Self::Unexpected(message.to_string())
}
}