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("Not the owner of the crate {0}")]
22    NotOwner(String),
23    #[error(
24        "Crate name {0} is too similar to the existing crate {1}, names must not only differ in '-' and '_'"
25    )]
26    CrateNameConflict(String, String),
27    #[error("Crate not found: {0}")]
28    CrateNotFound(String),
29    #[error("Crate with not found with id: {0}")]
30    CrateNotFoundWithId(i64),
31    #[error("Failed to count crate versions")]
32    FailedToCountCrateVersions,
33    #[error("Failed to count total crate downloads")]
34    FailedToCountTotalDownloads,
35    #[error("Failed to get crate summary for crate {0}")]
36    FailedToGetCrateSummary(String),
37    #[error("Token not found")]
38    TokenNotFound,
39    #[error("Session not found")]
40    SessionNotFound,
41    #[error("Failed to count all unique crates")]
42    FailedToCountCrates,
43    #[error("Crate meta information for crate {0} version {1} not found")]
44    CrateMetaNotFound(String, String),
45    #[error("Failed to get max version of crate id {0}")]
46    FailedToGetMaxVersionById(i64),
47    #[error("Failed to get max version of crate {0}")]
48    FailedToGetMaxVersionByName(String),
49    #[error("Invalid crate version {0}")]
50    InvalidVersion(String),
51    #[error("Failed to convert data to json: {0}")]
52    FailedToConvertToJson(String),
53    #[error("Failed to convert data from json: {0}")]
54    FailedToConvertFromJson(String),
55    #[error("Crate index not found for crate {0} - version {1}")]
56    CrateIndexNotFound(String, String),
57    #[error("Invalid crate name {0}")]
58    InvalidCrateName(String),
59    #[error("Crates.io index data is missing for crate {0}")]
60    MissingCratesIoIndexData(String),
61    #[error("Webhook not found")]
62    WebhookNotFound,
63    #[error("Invalid webhook event {0}")]
64    InvalidWebhookEvent(String),
65    #[error("Invalid id {0}")]
66    InvalidId(String),
67}