1use error_support::{ErrorHandling, GetErrorHandling};
10
11use remote_settings::RemoteSettingsError;
12
13#[derive(Debug, thiserror::Error)]
17pub enum Error {
18 #[error("Search configuration not specified")]
19 SearchConfigNotSpecified,
20 #[error("Search configuration overrides not specified")]
21 SearchConfigOverridesNotSpecified,
22 #[error("No search config v2 records received from remote settings")]
23 SearchConfigNoRecords,
24 #[error("No search config overrides v2 records received from remote settings")]
25 SearchConfigOverridesNoRecords,
26 #[error("JSON error: {0}")]
27 Json(#[from] serde_json::Error),
28 #[error("Remote Settings error: {0}")]
29 RemoteSettings(#[from] RemoteSettingsError),
30}
31
32#[derive(Debug, thiserror::Error, uniffi::Error)]
34pub enum SearchApiError {
35 #[error("Other error: {reason}")]
36 Other { reason: String },
37}
38
39impl GetErrorHandling for Error {
41 type ExternalError = SearchApiError;
42
43 fn get_error_handling(&self) -> ErrorHandling<Self::ExternalError> {
44 ErrorHandling::convert(SearchApiError::Other {
45 reason: self.to_string(),
46 })
47 .report_error("search-unexpected")
48 }
49}