Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Commit

Permalink
chore: use thiserror
Browse files Browse the repository at this point in the history
  • Loading branch information
saenai255 committed Sep 5, 2022
1 parent 009febc commit 4374d8d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ serde = { version = "1.0.144", features = ["derive"] }
chrono = { version = "0.4.22", features = ["serde"] }
serde_derive = "1.0.144"
serde_json = "1.0.85"
thiserror = "1.0"

[dev-dependencies]
rstest = "0.15.0"
1 change: 1 addition & 0 deletions src/store/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::model::{PacBuild, Repository};
use crate::store::errors::StoreError;
use crate::store::filters::{InstallState, Kind};

/// Alias for store error results
pub type StoreResult<T> = Result<T, StoreError>;

/// Abstraction over the caching implementation
Expand Down
15 changes: 14 additions & 1 deletion src/store/errors.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
//! Errors used by the caching system

use thiserror::Error;

/// Errors used by Base
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Error)]
pub enum StoreError {
#[error("repository '{0}' could not be found")]
RepositoryNotFound(String),

#[error("pacbuild '{name:?}' could not be found in repository {repository:?}")]
PacBuildNotFound { name: String, repository: String },

#[error("repository '{0}' already exists")]
RepositoryConflict(String),

#[error("pacbuild '{name:?}' already exists in repository {repository:?}")]
PacBuildConflict { name: String, repository: String },

#[error("unexpected error: {0}")]
Unexpected(String),

#[error("multiple errors: {0:?}")]
Aggregate(Vec<StoreError>),
}

0 comments on commit 4374d8d

Please sign in to comment.