jldb/lib/errs/fmt.go
2023-10-13 11:43:27 +02:00

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
}