Cause is an unnecessary construct I think.
Why not just point to another relevant error?
So we just get a linked list.
All relevant error constructs should implement error, so they behave like any other error in Rust, making it easier to use the library.
We can use the thiserror crate
Proposed change
[ ] Remove Cause struct.
[ ] Change WithCause trait to WithErr<T>, for relevant errors
[ ] Make ParseErr and LexErr derive Error
[ ] Make TypeErr and derive Error
[ ] Introduce new TypeErr struct which has internal vector of TypeErrs
Let this struct also derive Error.
If we add a new method which behaves similar to the new of TypeErr, we can use this in all situations where we have to manually construct a vector of errors.
Summary of current issue
Error implementation could be made more elegant:
Cause
is an unnecessary construct I think. Why not just point to another relevant error? So we just get a linked list.Proposed change
Cause
struct.WithCause
trait toWithErr<T>
, for relevant errorsParseErr
andLexErr
deriveError
TypeErr
and deriveError
TypeErr
struct which has internal vector ofTypeErrs
Let this struct also deriveError
. If we add anew
method which behaves similar to thenew
ofTypeErr
, we can use this in all situations where we have to manually construct a vector of errors.UnimplementedErr
deriveError