Updating iodine

master
Frederick F. Kautz IV 10 years ago
parent 938a0fa4a9
commit 2acd66ae96
  1. 2
      Godeps/Godeps.json
  2. 17
      Godeps/_workspace/src/github.com/minio-io/iodine/iodine.go
  3. 2
      Godeps/_workspace/src/github.com/minio-io/iodine/iodine_test.go

2
Godeps/Godeps.json generated vendored

@ -20,7 +20,7 @@
},
{
"ImportPath": "github.com/minio-io/iodine",
"Rev": "3d54fa6339544392a0eaadcf2692fbc94d4ac21d"
"Rev": "f2dbd51c3b4f8530a9b8e2dbc32788175df2fa5c"
},
{
"ImportPath": "gopkg.in/check.v1",

@ -25,6 +25,8 @@ import (
"strconv"
)
// Error is the iodine error which contains a pointer to the original error
// and stack traces.
type Error struct {
EmbeddedError error `json:"-"`
ErrorMessage string
@ -32,6 +34,7 @@ type Error struct {
Stack []StackEntry
}
// StackEntry contains the entry in the stack trace
type StackEntry struct {
Host string
File string
@ -39,6 +42,8 @@ type StackEntry struct {
Data map[string]string
}
// Wrap an error, turning it into an iodine error.
// Adds an initial stack trace.
func Wrap(err error, data map[string]string) *Error {
entry := createStackEntry()
for k, v := range data {
@ -63,22 +68,23 @@ func createStackEntry() StackEntry {
return entry
}
// Annotate an error with a stack entry and returns itself
func (err *Error) Annotate(info map[string]string) *Error {
data := make(map[string]string)
if info != nil {
for k, v := range info {
data[k] = v
}
for k, v := range info {
data[k] = v
}
entry := createStackEntry()
err.Stack = append(err.Stack, entry)
return err
}
func (err Error) EmitJson() ([]byte, error) {
// EmitJSON writes JSON output for the error
func (err Error) EmitJSON() ([]byte, error) {
return json.Marshal(err)
}
// EmitHumanReadable returns a human readable error message
func (err Error) EmitHumanReadable() string {
var errorBuffer bytes.Buffer
fmt.Fprintln(&errorBuffer, err.Error())
@ -88,6 +94,7 @@ func (err Error) EmitHumanReadable() string {
return string(errorBuffer.Bytes())
}
// Emits the original error message
func (err Error) Error() string {
return err.EmbeddedError.Error()
}

@ -32,7 +32,7 @@ func TestIodine(t *testing.T) {
if len(iodineError.Stack) != 4 {
t.Fail()
}
jsonResult, err := iodineError.EmitJson()
jsonResult, err := iodineError.EmitJSON()
if err != nil {
t.Fail()
}

Loading…
Cancel
Save