forked from TrueCloudLab/frostfs-node
[#446] los: Wrap SSD errors in a separate type
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
20b84f183a
commit
fe01781811
27 changed files with 202 additions and 76 deletions
33
pkg/local_object_storage/internal/metaerr/error.go
Normal file
33
pkg/local_object_storage/internal/metaerr/error.go
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue