This can be fixed by swapping the case statements: func debugerr(t *testing.T, err error) { t.Logf("Error, %v", err) switch err := err.
.Error: t.Logf("err: %s, nested err: %#v", err, err.Err) if operr, ok := err.Err.