1use std::path::PathBuf;
20
21use hyper::header::{InvalidHeaderValue, ToStrError};
22use thiserror::Error;
23use url::ParseError;
24
25#[derive(Error, Debug)]
30pub enum Error {
31 #[error(transparent)]
33 AdminError(#[from] mz_frontegg_client::error::Error),
34 #[error(transparent)]
36 ApiError(#[from] mz_cloud_api::error::Error),
37 #[error(transparent)]
39 AuthError(#[from] mz_frontegg_auth::Error),
40 #[error(
42 "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."
43 )]
44 UrlParseError(#[from] ParseError),
45 #[error("Error parsing JSON: {0}")]
47 JsonParseError(#[from] serde_json::Error),
48 #[error("Error parsing request JSON: {0}")]
50 ReqwestJsonParseError(#[from] reqwest::Error),
51 #[error(
53 "Error: {0}. \n\nTo resolve this issue, please verify the correctness of the app-password in the configuration file."
54 )]
55 AppPasswordParseError(#[from] mz_frontegg_auth::AppPasswordParseError),
56 #[error("Error: The current profile does not have an app-password.")]
58 AppPasswordMissing,
59 #[error(
61 "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`"
62 )]
63 ProfilesMissing,
64 #[error(
66 "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>`."
67 )]
68 ProfileMissing(String),
69 #[error("Cloud region not found.")]
71 CloudRegionMissing,
72 #[error("Error parsing TOML file: {0}")]
74 TomlParseError(#[from] toml_edit::de::Error),
75 #[error("Error serializing the profile: {0}")]
77 TomlSerializingError(#[from] toml::ser::Error),
78 #[error(transparent)]
80 TomlError(#[from] toml_edit::TomlError),
81 #[error(transparent)]
83 UuidError(#[from] uuid::Error),
84 #[error("Failed to execute command: {0}")]
86 CommandExecutionError(String),
87 #[error("Command failed: {0}")]
89 CommandFailed(String),
90 #[error(transparent)]
92 IOError(#[from] std::io::Error),
93 #[error("Error: The configuration file {0} is not writable: {1}")]
95 ConfigFileNotWritable(PathBuf, #[source] std::io::Error),
96 #[error(transparent)]
98 CSVParseError(#[from] csv::Error),
99 #[error("Login canceled.")]
101 LoginOperationCanceled,
102 #[error("Invalid app-password.")]
105 InvalidAppPassword,
106 #[error("The region is not ready yet.")]
109 NotReadyRegion,
110 #[error("The region is not resolvable yet.")]
113 NotResolvableRegion,
114 #[error("Timeout reached. Error: {0}")]
116 TimeoutError(Box<Error>),
118 #[error("The region is not ready to accept SQL statements. `pg_isready` failed.")]
121 NotPgReadyError,
122 #[error("Error parsing semver. Description: {0}")]
124 SemVerParseError(semver::Error),
125 #[error("Error retrieving the current timestamp.")]
128 TimestampConversionError,
129 #[error("Error parsing header value: {0}")]
131 HeaderParseError(InvalidHeaderValue),
132 #[error("Error. Cache dir not found")]
134 CacheDirNotFoundError,
135 #[error("Error parsing a request header. Description: {0}")]
137 HeaderToStrError(ToStrError),
138 #[error(
141 "Error the latest version header from the redirect request was not found. Verify the request is redirecting."
142 )]
143 LatestVersionHeaderMissingError,
144 #[error("An error occurred while trying to find the home directory.")]
146 HomeDirNotFoundError,
147 #[error("Error using keychain. {0}")]
150 MacOsSecurityError(String),
151 #[error("Vault value for the profile is invalid.")]
153 InvalidVaultError,
154 #[error(
156 "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."
157 )]
158 ProfileNameAlreadyExistsError(String),
159 #[error("Invalid secret expression: {0}")]
161 InvalidSecretExpression(String),
162}