|
|
@ -19,6 +19,7 @@ package iodine |
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"bytes" |
|
|
|
"bytes" |
|
|
|
"encoding/json" |
|
|
|
"encoding/json" |
|
|
|
|
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
"os" |
|
|
|
"os" |
|
|
|
"path" |
|
|
|
"path" |
|
|
@ -93,6 +94,27 @@ func GetGlobalStateKey(k string) string { |
|
|
|
return result |
|
|
|
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.
|
|
|
|
// New - instantiate an error, turning it into an iodine error.
|
|
|
|
// Adds an initial stack trace.
|
|
|
|
// Adds an initial stack trace.
|
|
|
|
func New(err error, data map[string]string) error { |
|
|
|
func New(err error, data map[string]string) error { |
|
|
|