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.
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