holochain/holochain-rust

Support better chaining of errors with error_chain

Closed this issue · 2 comments

Support better chaining of errors, e.g. with the error-chain crate,

https://github.com/rust-lang-nursery/error-chain

Context:

Better passing of a header/entry mismatch error custom error that I've made into a validation error added here:

pub fn try_from_entry_and_header(
entry: Entry,
header: ChainHeader,
) -> Result<EntryWithHeader, HolochainError> {
if entry.address() != *header.entry_address() {
Err(HolochainError::ValidationFailed(String::from(
"Entry/Header mismatch",

I see that there is custom code for error handling in https://github.com/holochain/holochain-rust/blob/develop/crates/core_types/src/error/mod.rs, but unless I am mistaken, it seems like in practice errors may not be chained, e.g. as shown in the above example, where it seems like it would be better to have a custom error for the entry/header mismatch.