Skip to content

Draft: add next-generation error trait

Charles Hall requested to merge charles/error-ng into main

Rust's standard library's error trait leaves a lot to be desired, especially with regards to handling groups of errors and transparent wrappers over other errors. This is an attempt to fix that.

To-do list:

  • New error trait.
  • Error forest traversal.
  • Put core and ng modules behind feature flags. (Don't forget to test feature combinations.)
    • Too annoying, not doing this.
  • Decide whether Errors should be cloneable (via dyn-clone).
    • I've dropped dyn-clone because it currently requires alloc rather than just core. Maybe a core-only dyn-clone is possible since the Clone trait is actually in core, but I dunno. Anyway, it would be really nice if this new error trait was core-only, which means dyn-clone has to go away.
  • Add impl<E: Error + ?Sized> Error for SmartPointer<E> impls.
  • Add a compatibility newtype wrapper for core::error::Error.
  • Convenience functions for formatting/printing an error forest.
  • Support downcasting.
  • Procedural macro for implementing Error on structs and enums.
  • More?
Edited by Charles Hall

Merge request reports

Loading