mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Add APIErrorWrapper so that underlying errors can be logged (#1246)
This commit is contained in:
@@ -194,3 +194,26 @@ type ErrorWrapper struct {
|
||||
func (m *ErrorWrapper) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// APIErrorWrapper wraps an error with an APIError such that the APIError
|
||||
// governs the HTTP response but the root error remains accessible.
|
||||
type APIErrorWrapper interface {
|
||||
APIError
|
||||
RootError() error
|
||||
}
|
||||
|
||||
type apiErrorWrapper struct {
|
||||
APIError
|
||||
root error
|
||||
}
|
||||
|
||||
func (w apiErrorWrapper) RootError() error {
|
||||
return w.root
|
||||
}
|
||||
|
||||
func NewAPIErrorWrapper(apiErr APIError, rootErr error) APIErrorWrapper {
|
||||
return &apiErrorWrapper{
|
||||
APIError: apiErr,
|
||||
root: rootErr,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user