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.0 KiB
61 lines
1.0 KiB
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"errs"
|
|
"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() {
|
|
|
|
ercode := errs.ErrCode("error->err-code")
|
|
fmt.Print(ercode.String())
|
|
fmt.Print("\n")
|
|
|
|
erpanic := errs.NewErrPanic("error->err-mensaje-panico")
|
|
fmt.Print(erpanic.String())
|
|
fmt.Print("\n")
|
|
|
|
ercause := ercode.ToErrCause(errs.ErrCode("error->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")
|
|
*/
|
|
|
|
}
|