frostfs-node/pkg/local_object_storage/internal/metaerr/error.go
Evgenii Stratonikov fe01781811 [#446] los: Wrap SSD errors in a separate type
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2023-06-16 14:53:31 +03:00

33 lines
642 B
Go

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
}