[#446] los: Wrap SSD errors in a separate type

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-06-15 13:19:36 +03:00
parent 20b84f183a
commit fe01781811
27 changed files with 202 additions and 76 deletions

View file

@ -0,0 +1,33 @@
package metaerr
import "errors"
// Error is a wrapper for SSD-related errors.
// In our model it unites metabase, pilorama and write-cache errors.
type Error struct {
err error
}
// New returns simple error with a provided error message.
func New(msg string) Error {
return Error{err: errors.New(msg)}
}
// Error implements the error interface.
func (e Error) Error() string {
return e.err.Error()
}
// Wrap wraps arbitrary error.
// Returns nil if err == nil.
func Wrap(err error) error {
if err != nil {
return Error{err: err}
}
return nil
}
// Unwrap returns underlying error.
func (e Error) Unwrap() error {
return e.err
}