Skip to content

Refactor errors in STM library #2764

@jpraynaud

Description

@jpraynaud

Why

The error system in the STM library is hard to understand and maintain. It needs to be refactored with the best practices used in the Mithril nodes which are specified in this ADR.

What

Refactor the errors in the STM library according to best practices.

How

  • Create a new StdResult<T> type in STM library which is an alias of anyhow::Result<T>
  • Update the return types of functions to StdResult:
    • Keep using the thiserror typed error in the functions
    • Add some anyhow context when necessary (e.g. if a function is called at multiple places)
    • Adapt tests to support testing a downcasted anyhow error to a thiserror typed error (a macro could help)
  • Remove the From/Into implementations for typed errors
  • Remove the unneeded variants of typed errors if any

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions