cf3fd00350
* - standardise versions for all nym-sdk workspace dependencies - prepend sqlx-pool-guard with 'nym-' * Test remove nym-api from deps * Add oneliner to client_pool doc comments * Add note to commented out docs.rs link in sdk * remove nym-api from script * add publishing file * bring non-binary / contract / tools into workspace version * added more info to publishing.md * make deps workspace version * remove uploaded sphinx-types crate from script * remove erroueously included ignore-defaults * add zeroise to feature * chore: Release * add topology to batch * more cargo versioning * more cargo versioning - wasm utils * more cargo versioning - wasm utils * Add publish=false to manifest for cargo workspaces / crates.io publishing exclusion * remove script now switched to manifest based exclusion * rename import based on rename of contracts-common dep * Making workspace versions for publication + removing unnecessary crates from publication * Remove OOD info from publishing sdk guide * rename contract imports + remove package * temp commit: continuing with removal of path from cargo manifest and replacing with workspace version import for publication * continuing with cargo.toml updates * dryrun only erroring on known version problem crates * remove old published-crates file * Minor comment change * remove default features warning * Additional info on workspace dep comment re publish list * Add missing description to cargo.toml * Fix missing feature flags * Add missing descriptions * Fix remaining path import * Add workspace repo / homepage / documentation links to cargo.toml files * remove workspace version from excluded crate * Remove todo descriptions * Minor comment change * add homepage etc * move from bls git import to nym_bls_fork crate * Modify rest of imports from path to workspace import, excluding binaries * add directory/homepage info * fix cargo fmt * add notes to gitignore * better solution to contracts/ experiment * wasm -> nym_wasm crate renaming * fix fatfinger * add metadata to ecash cargo.toml * stub publishing guide * fix misrevolved netlink- version * Fixes and block publication of rebase re: LP * first pass @ workflows
68 lines
2.0 KiB
Rust
68 lines
2.0 KiB
Rust
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
use nym_wasm_utils::error::simple_js_error;
|
|
use serde_wasm_bindgen::Error;
|
|
use thiserror::Error;
|
|
use wasm_bindgen::JsValue;
|
|
|
|
#[derive(Debug, Error)]
|
|
pub enum StorageError {
|
|
#[error("{0}")]
|
|
Json(String),
|
|
|
|
#[error("storage failure: {message}")]
|
|
InternalStorageFailure { message: String },
|
|
|
|
#[error("failed to open the db file: {message}")]
|
|
DbOpenFailure { message: String },
|
|
|
|
#[error("FATAL ERROR: storage key is somehow present {count} times in the table!")]
|
|
DuplicateKey { count: u32 },
|
|
|
|
#[error("encountered issue with our storage encryption layer: {source}")]
|
|
CryptoStorageError {
|
|
#[from]
|
|
source: nym_store_cipher::Error,
|
|
},
|
|
|
|
#[error(
|
|
"attempted to unlock an existing encrypted client store without providing a passphrase"
|
|
)]
|
|
NoPassphraseProvided,
|
|
|
|
#[error("attempted to access an existing unencrypted client store with a passphrase")]
|
|
UnexpectedPassphraseProvided,
|
|
}
|
|
|
|
impl From<StorageError> for JsValue {
|
|
fn from(value: StorageError) -> Self {
|
|
simple_js_error(value.to_string())
|
|
}
|
|
}
|
|
|
|
impl From<indexed_db_futures::error::Error> for StorageError {
|
|
fn from(value: indexed_db_futures::error::Error) -> Self {
|
|
StorageError::InternalStorageFailure {
|
|
message: value.to_string(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<indexed_db_futures::error::OpenDbError> for StorageError {
|
|
fn from(value: indexed_db_futures::error::OpenDbError) -> Self {
|
|
StorageError::DbOpenFailure {
|
|
message: value.to_string(),
|
|
}
|
|
}
|
|
}
|
|
|
|
// covert it to String so that we wouldn't store `JsValue` indirectly
|
|
// thus not making us !Send + !Sync
|
|
// (we could have done bunch of target locking elsewhere instead, but this solution is way simpler)
|
|
impl From<serde_wasm_bindgen::Error> for StorageError {
|
|
fn from(value: Error) -> Self {
|
|
StorageError::Json(value.to_string())
|
|
}
|
|
}
|