mirror of
https://github.com/minio/minio.git
synced 2026-11-28 07:30:50 +00:00
Adding iodine error conversion
This commit is contained in:
1 parent
e2c54a0904
commit
c12d5ea8a9
2 files changed
+35
No files matched your search
@@ -19,6 +19,7 @@ package iodine
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
@@ -93,6 +94,27 @@ func GetGlobalStateKey(k string) string {
|
||||
return result
|
||||
}
|
||||
|
||||
func ToError(err error) error {
|
||||
switch err := err.(type) {
|
||||
case nil:
|
||||
{
|
||||
return nil
|
||||
}
|
||||
case Error:
|
||||
{
|
||||
if err.EmbeddedError != nil {
|
||||
return err.EmbeddedError
|
||||
} else {
|
||||
return errors.New(err.ErrorMessage)
|
||||
}
|
||||
}
|
||||
default:
|
||||
{
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// New - instantiate an error, turning it into an iodine error.
|
||||
// Adds an initial stack trace.
|
||||
func New(err error, data map[string]string) error {
|
||||
|
||||
Reference in new issue
Block a user