❗ Rust Errors

Common problems

Error is not the same Error type as the function return type

  1. Define a GenericResult:
type GenericError = Box<dyn std::error::Error + Send + Sync + 'static>;
type GenericResult<T> = Result<T, GenericError>;
  1. Use GenericResult as a result type
  2. Use anyhow crate (preferred)