Skip to main content

kellnr_db/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum DbError {
5    #[error("Postgres error occurred: {0}")]
6    PostgresError(#[from] sea_orm::DbErr), // TODO find a good way to remove "postgres" as dependency here
7    #[error("Passwords did not match")]
8    PasswordMismatch,
9    #[error("Failed to get parent directory for index")]
10    NoIndexParentDirectory,
11    #[error("Failed to create database directory")]
12    CreateDatabaseDirectoryError,
13    #[error("Failed to initialize the database: {0}")]
14    InitializationError(String),
15    #[error("User not found: {0}")]
16    UserNotFound(String),
17    #[error("Group not found: {0}")]
18    GroupNotFound(String),
19    #[error("Owner not found: {0}")]
20    OwnerNotFound(String),
21    #[error("Crate not found: {0}")]
22    CrateNotFound(String),
23    #[error("Crate with not found with id: {0}")]
24    CrateNotFoundWithId(i64),
25    #[error("Failed to count crate versions")]
26    FailedToCountCrateVersions,
27    #[error("Failed to count total crate downloads")]
28    FailedToCountTotalDownloads,
29    #[error("Failed to get crate summary for crate {0}")]
30    FailedToGetCrateSummary(String),
31    #[error("Token not found")]
32    TokenNotFound,
33    #[error("Session not found")]
34    SessionNotFound,
35    #[error("Failed to count all unique crates")]
36    FailedToCountCrates,
37    #[error("Crate meta information for crate {0} version {1} not found")]
38    CrateMetaNotFound(String, String),
39    #[error("Failed to get max version of crate id {0}")]
40    FailedToGetMaxVersionById(i64),
41    #[error("Failed to get max version of crate {0}")]
42    FailedToGetMaxVersionByName(String),
43    #[error("Invalid crate version {0}")]
44    InvalidVersion(String),
45    #[error("Failed to convert data to json: {0}")]
46    FailedToConvertToJson(String),
47    #[error("Failed to convert data from json: {0}")]
48    FailedToConvertFromJson(String),
49    #[error("Crate index not found for crate {0} - version {1}")]
50    CrateIndexNotFound(String, String),
51    #[error("Invalid crate name {0}")]
52    InvalidCrateName(String),
53    #[error("Crates.io index data is missing for crate {0}")]
54    MissingCratesIoIndexData(String),
55    #[error("Webhook not found")]
56    WebhookNotFound,
57    #[error("Invalid webhook event {0}")]
58    InvalidWebhookEvent(String),
59    #[error("Invalid id {0}")]
60    InvalidId(String),
61}