/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use crate::client::error::ComponentError; use error_support::{ErrorHandling, GetErrorHandling}; pub type AdsClientApiResult = std::result::Result; #[derive(Debug, thiserror::Error, uniffi::Error)] pub enum MozAdsClientApiError { #[error("Something unexpected occurred.")] Other { reason: String }, } impl From for MozAdsClientApiError { fn from(err: context_id::ApiError) -> Self { MozAdsClientApiError::Other { reason: err.to_string(), } } } impl GetErrorHandling for ComponentError { type ExternalError = MozAdsClientApiError; fn get_error_handling(&self) -> ErrorHandling { ErrorHandling::convert(MozAdsClientApiError::Other { reason: self.to_string(), }) } }