-
Notifications
You must be signed in to change notification settings - Fork 111
Open
Description
There is an rest.Error
type that captures all unrecognized errors from Hooks:
if err = rsrc.Update(ctx, item, original); err != nil {
e = NewError(err)
return e.Code, nil, e
}
func NewError(err error) *Error {
switch err {
...
default:
return &Error{520, err.Error(), nil}
}
}
However sometimes, enriched errors are used(preserving call-trace), that become useless once stringed through err.Error()
. Can we preseve original error like this:
// Error defines a REST error with optional per fields error details.
type Error struct {
// Code defines the error code to be used for the error and for the HTTP
// status.
Code int
// Message is the error message.
Message string
// Issues holds per fields errors if any.
Issues map[string][]interface{}
Err error // Or even Errs []error
}
So I can use the errors in func (r ResponseFormatter) FormatError(
and send them to say Sentry or logs.
This might be a breaking change if someone is not following go vet
recommendations(like in rest-layer
source code :)
Metadata
Metadata
Assignees
Labels
No labels