diff --git a/crates/bitwarden-wasm-internal/src/crypto.rs b/crates/bitwarden-wasm-internal/src/crypto.rs index 3a5c972b6..a328a1c37 100644 --- a/crates/bitwarden-wasm-internal/src/crypto.rs +++ b/crates/bitwarden-wasm-internal/src/crypto.rs @@ -16,22 +16,12 @@ impl ClientCrypto { /// Initialization method for the user crypto. Needs to be called before any other crypto /// operations. pub async fn initialize_user_crypto(&self, req: InitUserCryptoRequest) -> Result<()> { - Ok(self - .0 - .crypto() - .initialize_user_crypto(req) - .await - .map_err(bitwarden_core::Error::EncryptionSettings)?) + Ok(self.0.crypto().initialize_user_crypto(req).await?) } /// Initialization method for the organization crypto. Needs to be called after /// `initialize_user_crypto` but before any other crypto operations. pub async fn initialize_org_crypto(&self, req: InitOrgCryptoRequest) -> Result<()> { - Ok(self - .0 - .crypto() - .initialize_org_crypto(req) - .await - .map_err(bitwarden_core::Error::EncryptionSettings)?) + Ok(self.0.crypto().initialize_org_crypto(req).await?) } } diff --git a/crates/bitwarden-wasm-internal/src/error.rs b/crates/bitwarden-wasm-internal/src/error.rs index 35f0d46a5..2750d2629 100644 --- a/crates/bitwarden-wasm-internal/src/error.rs +++ b/crates/bitwarden-wasm-internal/src/error.rs @@ -10,24 +10,18 @@ extern "C" { fn new(message: String) -> WasmError; } -pub type Result = std::result::Result; +pub type Result = std::result::Result; -pub struct Error(bitwarden::error::Error); +pub struct GenericError(pub String); -impl From for Error { - fn from(error: bitwarden::error::Error) -> Self { - Self(error) +impl From for GenericError { + fn from(error: T) -> Self { + GenericError(error.to_string()) } } -impl From for Error { - fn from(error: bitwarden::Error) -> Self { - Self(error.into()) - } -} - -impl From for JsValue { - fn from(error: Error) -> Self { - WasmError::new(error.0.to_string()).into() +impl From for JsValue { + fn from(error: GenericError) -> Self { + WasmError::new(error.0).into() } }