23 lines
405 B
Go
23 lines
405 B
Go
package errs
|
|
|
|
import "fmt"
|
|
|
|
func FmtDetails(err error) string {
|
|
e, ok := err.(*Error)
|
|
if !ok {
|
|
return err.Error()
|
|
}
|
|
|
|
var s string
|
|
if e.collection != "" || e.index != "" {
|
|
s = fmt.Sprintf(`[%d] (%s/%s) %s`, e.Code, e.collection, e.index, e.Msg)
|
|
} else {
|
|
s = fmt.Sprintf("[%d] %s", e.Code, e.Msg)
|
|
}
|
|
if len(e.StackTrace) != 0 {
|
|
s += "\n\nStack Trace:\n" + e.StackTrace + "\n"
|
|
}
|
|
|
|
return s
|
|
}
|