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.
108 lines
1.7 KiB
108 lines
1.7 KiB
package main
|
|
|
|
import (
|
|
"bins/bfers"
|
|
"errs"
|
|
"errs/fmtr/collr"
|
|
"errs/fmtr/fjson"
|
|
"errs/stack"
|
|
"fmt"
|
|
)
|
|
|
|
|
|
func printTrace (s stack.Trace) {
|
|
lf := s.Frames()
|
|
for i,f := range lf {
|
|
fmt.Printf("%d file %s line %d %s\n",i,f.File,f.LineNumber,f.FuncName)
|
|
}
|
|
}
|
|
|
|
|
|
func GenerateBinaryString() string {
|
|
binaryString := ""
|
|
for c := 0; c < 255; c++ {
|
|
if ('a' <= byte(c) && byte(c) <= 'z') || ('A' <= byte(c) && byte(c) <= 'Z') || byte(c) == '@' {
|
|
binaryString += "1"
|
|
} else {
|
|
binaryString += "0"
|
|
}
|
|
}
|
|
return binaryString
|
|
}
|
|
|
|
|
|
|
|
|
|
type (
|
|
|
|
MiCustomErr struct {
|
|
error
|
|
ms string
|
|
}
|
|
)
|
|
|
|
func (c MiCustomErr) Message() string {
|
|
return "esto es un custom werro"
|
|
}
|
|
|
|
func (c MiCustomErr) Code() string {
|
|
return "custom-code"
|
|
}
|
|
|
|
|
|
/*
|
|
func fm (b *bytes.Buffer, e error, l int) {
|
|
b.WriteString("Link :"+e.(MiCustomErr).Link+"\n")
|
|
}
|
|
*/
|
|
|
|
func (c MiCustomErr) Error () string {
|
|
return "ERRRROPROO"
|
|
}
|
|
|
|
func (c MiCustomErr) Unwrap () error {
|
|
return c.error
|
|
}
|
|
|
|
|
|
func printCollection (ec collr.ErrorCollection) {
|
|
if ec.Invalid != nil {
|
|
fmt.Printf("INvalid %s\n", ec.Invalid.Error())
|
|
}
|
|
ec.Fields.Sort()
|
|
|
|
fmt.Printf("Error: %s\n",ec.ErrStr)
|
|
fmt.Printf("Types: %d\n",len(ec.Types))
|
|
for _,t := range ec.Types {
|
|
fmt.Printf("\tWrap Type : %s\n",t.String())
|
|
}
|
|
fmt.Printf("Fields: \n")
|
|
for _,h := range ec.Fields.GetHeads() {
|
|
fmt.Printf("\t%s : %v\n",h.Name)
|
|
}
|
|
fmt.Printf("Causes: \n")
|
|
for _,c := range ec.Causes {
|
|
printCollection(c)
|
|
}
|
|
}
|
|
|
|
|
|
func main() {
|
|
|
|
|
|
me := errs.WrapWithInfo(bfers.G.ErrTooLarge.WrapWithCause(MiCustomErr{}),
|
|
errs.ErrInfoWithInfo("Mi mensaje"))
|
|
|
|
|
|
|
|
//printCollection(*collr.NewErrorCollection(me).Collect(true,true,true))
|
|
|
|
|
|
jso := fjson.NewJSONFormatter()
|
|
|
|
fmt.Print(string(jso.FormatError(me)))
|
|
|
|
}
|
|
|
|
|