onflow / atree

Atree provides scalable arrays and scalable ordered maps.
https://onflow.org
Apache License 2.0
40 stars 16 forks source link

Refactor error handling to user, fatal, and external errors #285

Closed fxamacker closed 1 year ago

fxamacker commented 1 year ago

Issue To Be Solved

Error handling and error passing between Atree, Cadence, and FVM needs to be improved.

Currently Atree errors are either fatal or non-fatal errors. Some external errors from FVM or Cadence are wrapped as fatal errors, which could be user errors instead, such as reaching interaction limit.

Suggested Solution

Refactor Atree error handling to 3 categories: user, fatal, and external errors. User errors are recoverable such as index out of bounds. Fatal errors are unrecoverable such as failing Atree data integrity check. External errors are wrapped errors from either FVM or Cadence. External errors should be handled by FVM or Cadence with more context.

Also make sure all Atree external errors implement Unwrap for idiomatic error handling.

Context

See https://github.com/onflow/cadence/issues/1255