Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Task] Design and implement a StorageError #920

Open
9 tasks
PhilippGackstatter opened this issue Jun 22, 2022 · 0 comments
Open
9 tasks

[Task] Design and implement a StorageError #920

PhilippGackstatter opened this issue Jun 22, 2022 · 0 comments
Labels
Breaking change A change to the API that requires a major release. Part of "Changed" section in changelog Rust Related to the core Rust code. Becomes part of the Rust changelog. Wasm Related to Wasm bindings. Becomes part of the Wasm changelog

Comments

@PhilippGackstatter
Copy link
Contributor

Description

Design and implement a StorageError that is returned from all Storage methods as Result<T, StorageError>.

For the design, we could take inspiration from serde::de::Error and how it handles custom errors.

We should consider providing some common variants that all implementations likely need:

#[derive(Debug, thiserror::Error)]
pub enum StorageError {
  #[error("requested operation `{0}` is not supported")]
  NotSupported(String),
  #[error("key at location `{0}` was not found")]
  KeyNotFound(String),
  #[error("DID `{0}` was not found")]
  DIDNotFound(String),
  #[error("TODO")]
  Custom(#[source] Box<dyn std::error::Error>)
}

Using Box<dyn std::error::Error> allows a caller to downcast to a concrete error type in case they want to handle errors from a specific implementation.

Motivation

The Storage trait currently uses identity_account_storage::error::Result in its return type, which means the Account error type needs to accommodate the possible storage error from both MemStore and Stronghold, as well as Wasm-specific variant such as identity_account_storage::error::Error::{SerializationError,JsError}. A dedicated StorageError allows for independent error types for our two implementations, as well as external implementations, and without polluting the existing error.

Resources

#597 (comment)

To-do list

Create a task-specific to-do list. Please link PRs that match the To-do list item behind the item after it has been submitted.

  • Introduce a separate MemStoreError that contains the specific errors from the account Error type that only the MemStore needs.
    • We can take this opportunity to use parking_lot::RwLock instead of std::sync::RwLock and get rid of the SharedReadPoisoned and SharedWritePoisoned error variants.
  • Design & implement the StorageError.

Change checklist

Add an x to the boxes that are relevant to your changes, and delete any items that are not.

  • The feature or fix is implemented in Rust and across all bindings whereas possible.
  • The feature or fix has sufficient testing coverage
  • All tests and examples build and run locally as expected
  • Every piece of code has been document according to the documentation guidelines.
  • If conceptual documentation (mdbook) and examples highlighting the feature exist, they are properly updated.
  • If the feature is not currently documented, a documentation task Issue has been opened to address this.
@PhilippGackstatter PhilippGackstatter added Wasm Related to Wasm bindings. Becomes part of the Wasm changelog Breaking change A change to the API that requires a major release. Part of "Changed" section in changelog Rust Related to the core Rust code. Becomes part of the Rust changelog. labels Jun 22, 2022
@PhilippGackstatter PhilippGackstatter added this to the v0.7 Features milestone Jun 22, 2022
@eike-hass eike-hass removed this from the v0.7 Features milestone Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking change A change to the API that requires a major release. Part of "Changed" section in changelog Rust Related to the core Rust code. Becomes part of the Rust changelog. Wasm Related to Wasm bindings. Becomes part of the Wasm changelog
Projects
Status: Product Backlog
Development

No branches or pull requests

2 participants