You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.1 KiB

3 years ago
package main
import (
"bytes"
3 years ago
"errs"
"fmt"
)
3 years ago
func printTrace (s errs.StackTrace) {
lf := s.Frames()
for i,f := range lf {
fmt.Printf("%d file %s line %d %s\n",i,f.File,f.LineNumber,f.FuncName)
}
3 years ago
}
type (
MiCustomErr struct {
error
Link string
}
)
func fm (b *bytes.Buffer, e error, l int) {
b.WriteString("Link :"+e.(MiCustomErr).Link+"\n")
}
func (m MiCustomErr) Unwrap () error {
return m.error
}
3 years ago
func main() {
3 years ago
//var MC MiCustomErr
//errs.G.Formatter.(*errs.FmtText).SetErrorFormatter(reflect.TypeOf(MC),fm)
3 years ago
eA := errs.ErrCode("1")
3 years ago
eB := errs.ErrCode("2")//.ToErrTrace(0)
eC := eA.ToErrCause(
eB.ToErrInfo(errs.ErrInfoWithCause(errs.ErrCode("--ARRROR---").ToErrInfo(errs.ErrInfoWithMessage("Mi Mensage"),
errs.ErrInfoWithStackTrace(3)))))
eM := MiCustomErr{
error: errs.NewErrInfo(eC,
errs.ErrInfoWithMessage("Esto es el mensaje"),
errs.ErrInfoWithInfo ("Informacion del error"),
errs.ErrInfoWithMeta("Mi-Meta",3434),
errs.ErrInfoWithMeta("Tu-Meta",22.34)),
Link : "mi-enlacea",
}
3 years ago
fmt.Print(string(errs.G.Formatter.Format(eM)))
3 years ago
3 years ago
}

Powered by TurnKey Linux.