wip: default writer tested

This commit is contained in:
2023-09-11 13:56:38 +10:00
parent d406fe698f
commit f482eb8631
5 changed files with 103 additions and 58 deletions

View File

@@ -0,0 +1,29 @@
package wrapped
import (
"fmt"
"gitea.suyono.dev/suyono/wingmate/debugframes"
"gitea.suyono.dev/suyono/wingmate/log"
"runtime/debug"
"testing"
)
func TestPrintWrappedError(t *testing.T) {
log.Print("test", fmt.Errorf("wrapped error trace%w", debugframes.GetTraces()))
}
func TestPrintWrappedPanic(t *testing.T) {
f := func() (err error) {
defer func() {
if o := recover(); o != nil {
err = fmt.Errorf("panic: %v%w", o, debugframes.PanicTrace(debug.Stack()))
}
}()
panic("test")
return nil
}
err := f()
log.Print("panic_test", err)
}