From e818bc71878d7399ff5eaab83b08e374519f1fed Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 23 Jun 2015 13:36:22 -0700 Subject: [PATCH] Trim iodine path properly, so that now errors have github.com/minio/minio prefixed --- pkg/iodine/iodine.go | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/pkg/iodine/iodine.go b/pkg/iodine/iodine.go index b297c7170..96903052a 100644 --- a/pkg/iodine/iodine.go +++ b/pkg/iodine/iodine.go @@ -51,7 +51,7 @@ type StackEntry struct { Data map[string]string } -var gopath string +var gopathSource string var globalState = struct { sync.RWMutex @@ -152,7 +152,7 @@ func createStackEntry() StackEntry { pc, file, line, _ := runtime.Caller(2) function := runtime.FuncForPC(pc).Name() _, function = filepath.Split(function) - file = strings.TrimPrefix(file, gopath) // trim gopath from file + file = strings.TrimPrefix(file, gopathSource) // trim gopathSource from file data := GetGlobalState() for k, v := range getSystemData() { @@ -190,14 +190,15 @@ func getSystemData() map[string]string { } // Annotate an error with a stack entry and returns itself -//func (err *WrappedError) Annotate(info map[string]string) *WrappedError { -// entry := createStackEntry() -// for k, v := range info { -// entry.Data[k] = v -// } -// err.Stack = append(err.Stack, entry) -// return err -//} +// +// func (err *WrappedError) Annotate(info map[string]string) *WrappedError { +// entry := createStackEntry() +// for k, v := range info { +// entry.Data[k] = v +// } +// err.Stack = append(err.Stack, entry) +// return err +// } // EmitJSON writes JSON output for the error func (err Error) EmitJSON() ([]byte, error) { @@ -222,8 +223,10 @@ func (err Error) Error() string { func init() { _, iodineFile, _, _ := runtime.Caller(0) - iodineFile = filepath.Dir(iodineFile) // trim iodine.go - iodineFile = filepath.Dir(iodineFile) // trim iodine - iodineFile = filepath.Dir(iodineFile) // trim minio - gopath = filepath.Dir(iodineFile) + "/" // trim github.com + iodineFile = filepath.Dir(iodineFile) // trim iodine.go + iodineFile = filepath.Dir(iodineFile) // trim iodine + iodineFile = filepath.Dir(iodineFile) // trim pkg + iodineFile = filepath.Dir(iodineFile) // trim minio + iodineFile = filepath.Dir(iodineFile) // trim minio + gopathSource = filepath.Dir(iodineFile) + "/" // trim github.com }