concordium-base icon indicating copy to clipboard operation
concordium-base copied to clipboard

Improve error handling abstractions in wasm-transform and wasm-chain-integration

Open abizjak opened this issue 3 years ago • 0 comments

Task description

The interpreter and wasm-chain integration often use anyhow::Error as an error type. This is for historical reasons since during initial development this is most flexible. We then use downcast to identify whether specific errors, such as OutOfEnergy occurred. We also have a number of other concrete errors that I needed during testing. Still there are some remaining errors that are just bail!("arbitrary string").

The ideal way of doing error handling is that each of the library methods (i.e., all of parsing, validation, interpreter) would return a precise error, which would be an enum. anyhow::Error should only be used in cargo-concordium at the application level.

This task is to get to this point.

Sub-tasks

  • [ ] replace anyhow::Error in wasm-transform functions with precise errors. Using thiserror crate to handle the boilerplate
  • [ ] replace anyhow::Error in wasm-chain-integration functions with precise errors. Using thiserror crate to handle the boilerplate
  • [ ] propagate changes

This will make error handling more robust. In particular with the current setup checking whether execution failed with out of energy, or whether it failed for some other reason is not clean and transparent.

abizjak avatar Jan 08 '22 08:01 abizjak