gossamer
gossamer copied to clipboard
pkg/scale: define sentinel errors and add error wrapping
Task summary
The pkg/scale
package is cumbersome to use together with error wrapping aware code, since no sentinel error is defined and exported.
All defined errors.New(
and fmt.Errorf(
constant strings errors should be moved to global scope and exported so callers can use them together with errors.Is(err, scale.ErrXXX)
. This can be useful for testing packages importing the scale package as well, where the (programmatic) error has to be asserted.
Standard library error wrapping with fmt.Errorf("doing something: %w", err)
should also be added at the same time to add more context to errors returned.
@qdm12 where in the gossamer codebase do we actually check error types?