unitycatalog_object_store/
error.rs1#[derive(Debug, thiserror::Error)]
2pub enum Error {
3 #[error("Invalid URL: {0}")]
4 InvalidUrl(String),
5
6 #[error("Invalid configuration: {0}")]
7 InvalidConfig(String),
8
9 #[error("Unity Catalog error: {source}")]
10 UnityCatalogError {
11 #[from]
12 source: unitycatalog_common::Error,
13 },
14
15 #[error("Unity Catalog error: {source}")]
16 ClientError {
17 #[from]
18 source: unitycatalog_client::Error,
19 },
20
21 #[error("The unity API response did not contain a credential")]
22 NoCredential,
23
24 #[error("Credential mismatch: {0}")]
25 CredentialMismatch(String),
26
27 #[error("Invalid credential: {0}")]
28 InvalidCredential(String),
29}
30
31impl Error {
32 pub fn invalid_config(msg: impl ToString) -> Self {
33 Error::InvalidConfig(msg.to_string())
34 }
35
36 pub fn credential_mismatch(msg: impl ToString) -> Self {
37 Error::CredentialMismatch(msg.to_string())
38 }
39
40 pub fn invalid_url(msg: impl ToString) -> Self {
41 Error::InvalidUrl(msg.to_string())
42 }
43}
44
45impl From<url::ParseError> for Error {
46 fn from(err: url::ParseError) -> Self {
47 Error::InvalidUrl(err.to_string())
48 }
49}
50
51impl From<Error> for object_store::Error {
52 fn from(err: Error) -> Self {
53 object_store::Error::Generic {
54 store: "unity",
55 source: Box::new(err),
56 }
57 }
58}