Skip to main content

deltalake_lakefs/
errors.rs

1//! Errors for LakeFS log store
2
3use deltalake_core::DeltaTableError;
4use deltalake_core::kernel::transaction::TransactionError;
5use reqwest::Error;
6
7#[derive(thiserror::Error, Debug)]
8pub enum LakeFSConfigError {
9    /// Missing endpoint
10    #[error("LakeFS endpoint is missing in storage options. Set `endpoint`.")]
11    EndpointMissing,
12
13    /// Missing username
14    #[error("LakeFS username is missing in storage options. Set `access_key_id`.")]
15    UsernameCredentialMissing,
16
17    /// Missing password
18    #[error("LakeFS password is missing in storage options. Set `secret_access_key`.")]
19    PasswordCredentialMissing,
20}
21
22#[derive(thiserror::Error, Debug)]
23pub enum LakeFSOperationError {
24    /// Failed to send http request to LakeFS
25    #[error("Failed to send request to LakeFS: {source}")]
26    HttpRequestFailed { source: Error },
27
28    /// Missing authentication in LakeFS
29    #[error("LakeFS request was unauthorized. Check permissions.")]
30    UnauthorizedAction,
31
32    /// LakeFS commit has failed
33    #[error("LakeFS commit failed. Reason: {0}")]
34    CommitFailed(String),
35
36    /// LakeFS merge has failed
37    #[error("LakeFS merge failed. Reason: {0}")]
38    MergeFailed(String),
39
40    /// LakeFS create branch has failed
41    #[error("LakeFS create branch failed. Reason: {0}")]
42    CreateBranchFailed(String),
43
44    /// LakeFS delete branch has failed
45    #[error("LakeFS delete branch failed. Reason: {0}")]
46    DeleteBranchFailed(String),
47
48    /// LakeFS delete branch has failed
49    #[error("Transaction ID ({0}) not found. Something went wrong.")]
50    TransactionIdNotFound(String),
51}
52
53impl From<LakeFSOperationError> for TransactionError {
54    fn from(err: LakeFSOperationError) -> Self {
55        TransactionError::LogStoreError {
56            msg: err.to_string(),
57            source: Box::new(err),
58        }
59    }
60}
61
62impl From<LakeFSOperationError> for DeltaTableError {
63    fn from(err: LakeFSOperationError) -> Self {
64        DeltaTableError::Transaction {
65            source: TransactionError::LogStoreError {
66                msg: err.to_string(),
67                source: Box::new(err),
68            },
69        }
70    }
71}
72
73impl From<LakeFSConfigError> for DeltaTableError {
74    fn from(err: LakeFSConfigError) -> Self {
75        DeltaTableError::GenericError {
76            source: Box::new(err),
77        }
78    }
79}