func TestCatchPanicNilClient(t *testing.T) { buf := new(bytes.Buffer) log.SetOutput(buf) defer func() { recover() body := buf.Bytes() if !strings.Contains(string(body), "divide by zero") { t.Errorf("error report didn't contain recovered value") } if !strings.Contains(string(body), "hello, error") { t.Errorf("error report didn't contain message") } if !strings.Contains(string(body), "errors_test.TestCatchPanicNilClient") { t.Errorf("error report didn't contain recovered value") } }() var c *errors.Client defer c.Catch(ctx, errors.WithMessage("hello, error")) var x int x = x / x }