package main import ( "bytes" "fmt" ) 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) } } 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 } func main() { //var MC MiCustomErr //errs.G.Formatter.(*errs.FmtText).SetErrorFormatter(reflect.TypeOf(MC),fm) eA := errs.ErrCode("1") 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 := errs.MakeErrMulti(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", }, errs.ErrCode("Otros errrores")) fmt.Print(string(errs.G.Formatter.Format(eM))) /* ercode := errs.ErrCode("err-code") fmt.Print(ercode.String()) fmt.Print("\n") erpanic := errs.NewErrPanic("err-mensaje-panico") fmt.Print(erpanic.String()) fmt.Print("\n") ercause := ercode.ToErrCause(errs.ErrCode("err-code-with-cause")) fmt.Print(ercause.String()) fmt.Print("\n") erInfo := errs.ErrCode("err-code-with-info").ToErrInfo(errs.ErrInfoWithMessage("Esto es un mensaje")) fmt.Print(erInfo.String()) fmt.Print("\n") ertrace := errs.ErrCode("err-code-with-trace").ToErrTrace(0) fmt.Print(ertrace.String()) fmt.Print("\n") */ }