mirror of
https://github.com/minio/minio.git
synced 2025-11-09 21:49:46 -05:00
Updating iodine to match new api
This commit is contained in:
16
Godeps/_workspace/src/github.com/minio-io/iodine/iodine.go
generated
vendored
16
Godeps/_workspace/src/github.com/minio-io/iodine/iodine.go
generated
vendored
@@ -30,7 +30,7 @@ import (
|
||||
|
||||
// WrappedError is the iodine error which contains a pointer to the original error
|
||||
// and stack traces.
|
||||
type WrappedError struct {
|
||||
type Error struct {
|
||||
EmbeddedError error `json:"-"`
|
||||
ErrorMessage string
|
||||
|
||||
@@ -90,20 +90,20 @@ func GetGlobalStateKey(k string) string {
|
||||
|
||||
// Error - instantiate an error, turning it into an iodine error.
|
||||
// Adds an initial stack trace.
|
||||
func Error(err error, data map[string]string) error {
|
||||
func New(err error, data map[string]string) error {
|
||||
if err != nil {
|
||||
entry := createStackEntry()
|
||||
var newErr WrappedError
|
||||
var newErr Error
|
||||
|
||||
// check if error is wrapped
|
||||
switch typedError := err.(type) {
|
||||
case WrappedError:
|
||||
case Error:
|
||||
{
|
||||
newErr = typedError
|
||||
}
|
||||
default:
|
||||
{
|
||||
newErr = WrappedError{
|
||||
newErr = Error{
|
||||
EmbeddedError: err,
|
||||
ErrorMessage: err.Error(),
|
||||
Stack: []StackEntry{},
|
||||
@@ -170,12 +170,12 @@ func getSystemData() map[string]string {
|
||||
//}
|
||||
|
||||
// EmitJSON writes JSON output for the error
|
||||
func (err WrappedError) EmitJSON() ([]byte, error) {
|
||||
func (err Error) EmitJSON() ([]byte, error) {
|
||||
return json.Marshal(err)
|
||||
}
|
||||
|
||||
// EmitHumanReadable returns a human readable error message
|
||||
func (err WrappedError) EmitHumanReadable() string {
|
||||
func (err Error) EmitHumanReadable() string {
|
||||
var errorBuffer bytes.Buffer
|
||||
fmt.Fprintln(&errorBuffer, err.ErrorMessage)
|
||||
for i, entry := range err.Stack {
|
||||
@@ -185,7 +185,7 @@ func (err WrappedError) EmitHumanReadable() string {
|
||||
}
|
||||
|
||||
// Emits the original error message
|
||||
func (err WrappedError) Error() string {
|
||||
func (err Error) Error() string {
|
||||
return err.EmitHumanReadable()
|
||||
}
|
||||
|
||||
|
||||
16
Godeps/_workspace/src/github.com/minio-io/iodine/iodine_test.go
generated
vendored
16
Godeps/_workspace/src/github.com/minio-io/iodine/iodine_test.go
generated
vendored
@@ -24,12 +24,12 @@ import (
|
||||
)
|
||||
|
||||
func TestIodine(t *testing.T) {
|
||||
iodineError := Error(errors.New("Hello"), nil)
|
||||
iodineError = Error(iodineError, nil)
|
||||
iodineError = Error(iodineError, nil)
|
||||
iodineError = Error(iodineError, nil)
|
||||
iodineError := New(errors.New("Hello"), nil)
|
||||
iodineError = New(iodineError, nil)
|
||||
iodineError = New(iodineError, nil)
|
||||
iodineError = New(iodineError, nil)
|
||||
switch typedError := iodineError.(type) {
|
||||
case WrappedError:
|
||||
case Error:
|
||||
{
|
||||
if len(typedError.Stack) != 4 {
|
||||
t.Fail()
|
||||
@@ -63,9 +63,9 @@ func TestState(t *testing.T) {
|
||||
t.Fail()
|
||||
}
|
||||
SetGlobalState("foo", "bar")
|
||||
err := Error(errors.New("a simple error"), nil)
|
||||
err := New(errors.New("a simple error"), nil)
|
||||
switch typedError := err.(type) {
|
||||
case WrappedError:
|
||||
case Error:
|
||||
{
|
||||
if res, ok := typedError.Stack[0].Data["foo"]; ok {
|
||||
if res != "bar" {
|
||||
@@ -74,7 +74,7 @@ func TestState(t *testing.T) {
|
||||
} else {
|
||||
t.Fail()
|
||||
}
|
||||
typedError = Error(typedError, map[string]string{"foo2": "bar2"}).(WrappedError)
|
||||
typedError = New(typedError, map[string]string{"foo2": "bar2"}).(Error)
|
||||
if res, ok := typedError.Stack[0].Data["foo"]; ok {
|
||||
if res != "bar" {
|
||||
t.Error("annotate should not modify previous data entries")
|
||||
|
||||
Reference in New Issue
Block a user