1use hyper::header::{InvalidHeaderValue, ToStrError};
20use thiserror::Error;
21use url::ParseError;
22
23#[derive(Error, Debug)]
28pub enum Error {
29 #[error(transparent)]
31 AdminError(#[from] mz_frontegg_client::error::Error),
32 #[error(transparent)]
34 ApiError(#[from] mz_cloud_api::error::Error),
35 #[error(transparent)]
37 AuthError(#[from] mz_frontegg_auth::Error),
38 #[error(
40 "Error parsing URL: {0}.\n\nTo resolve this issue, please verify the correctness of the URLs in the configuration file or the ones passed as parameters."
41 )]
42 UrlParseError(#[from] ParseError),
43 #[error("Error parsing JSON: {0}")]
45 JsonParseError(#[from] serde_json::Error),
46 #[error("Error parsing request JSON: {0}")]
48 ReqwestJsonParseError(#[from] reqwest::Error),
49 #[error(
51 "Error: {0}. \n\nTo resolve this issue, please verify the correctness of the app-password in the configuration file."
52 )]
53 AppPasswordParseError(#[from] mz_frontegg_auth::AppPasswordParseError),
54 #[error("Error: The current profile does not have an app-password.")]
56 AppPasswordMissing,
57 #[error(
59 "Error: No profiles available in the configuration file. \n\nTo resolve this issue, you can add a new profile using the following command: `mz profile init`"
60 )]
61 ProfilesMissing,
62 #[error(
64 "Error: The profile '{0}' is missing in the configuration file. \n\nTo resolve this issue, you can either: \n1. Add the missing profile using the command `mz profile --profile {0} init` \n2. Set another existing profile using the command: `mz config set profile <profile_name>`."
65 )]
66 ProfileMissing(String),
67 #[error("Cloud region not found.")]
69 CloudRegionMissing,
70 #[error("Error parsing TOML file: {0}")]
72 TomlParseError(#[from] toml_edit::de::Error),
73 #[error("Error serializing the profile: {0}")]
75 TomlSerializingError(#[from] toml::ser::Error),
76 #[error(transparent)]
78 TomlError(#[from] toml_edit::TomlError),
79 #[error(transparent)]
81 UuidError(#[from] uuid::Error),
82 #[error("Failed to execute command: {0}")]
84 CommandExecutionError(String),
85 #[error("Command failed: {0}")]
87 CommandFailed(String),
88 #[error(transparent)]
90 IOError(#[from] std::io::Error),
91 #[error(transparent)]
93 CSVParseError(#[from] csv::Error),
94 #[error("Login canceled.")]
96 LoginOperationCanceled,
97 #[error("Invalid app-password.")]
100 InvalidAppPassword,
101 #[error("The region is not ready yet.")]
104 NotReadyRegion,
105 #[error("The region is not resolvable yet.")]
108 NotResolvableRegion,
109 #[error("Timeout reached. Error: {0}")]
111 TimeoutError(Box<Error>),
113 #[error("The region is not ready to accept SQL statements. `pg_isready` failed.")]
116 NotPgReadyError,
117 #[error("Error parsing semver. Description: {0}")]
119 SemVerParseError(semver::Error),
120 #[error("Error retrieving the current timestamp.")]
123 TimestampConversionError,
124 #[error("Error parsing header value: {0}")]
126 HeaderParseError(InvalidHeaderValue),
127 #[error("Error. Cache dir not found")]
129 CacheDirNotFoundError,
130 #[error("Error parsing a request header. Description: {0}")]
132 HeaderToStrError(ToStrError),
133 #[error(
136 "Error the latest version header from the redirect request was not found. Verify the request is redirecting."
137 )]
138 LatestVersionHeaderMissingError,
139 #[error("An error occurred while trying to find the home directory.")]
141 HomeDirNotFoundError,
142 #[error("Error using keychain. {0}")]
145 MacOsSecurityError(String),
146 #[error("Vault value for the profile is invalid.")]
148 InvalidVaultError,
149 #[error(
151 "The profile name '{0}' already exists. You can either use 'mz profile init -f' to replace it or 'mz profile init --profile <PROFILE>' to choose another name."
152 )]
153 ProfileNameAlreadyExistsError(String),
154}