-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
If rendering has failed due to a net.OpError stop rendering (attempt 2) #19049
If rendering has failed due to a net.OpError stop rendering (attempt 2) #19049
Conversation
Unfortunately go-gitea#18642 does not work because a `*net.OpError` does not implement the `Is` interface to make `errors.Is` work correctly - thus leading to the irritating conclusion that a `*net.OpError` is not a `*net.OpError`. Here we keep the `errors.Is` because presumably this will be fixed at some point in the golang main source code but also we add a simply type cast to also check. Fix go-gitea#18629 Signed-off-by: Andrew Thornton <art27@cantab.net>
Here's a simple test case: package main
import (
"errors"
"fmt"
"net"
)
func main() {
opError := &net.OpError{Op: "write", Net: "", Err: fmt.Errorf("random")}
fmt.Println(opError)
fmt.Println(errors.Is(opError, &net.OpError{}))
} a |
@@ -269,7 +269,7 @@ func (ctx *Context) ServerError(logMsg string, logErr error) { | |||
func (ctx *Context) serverErrorInternal(logMsg string, logErr error) { | |||
if logErr != nil { | |||
log.ErrorWithSkip(2, "%s: %v", logMsg, logErr) | |||
if errors.Is(logErr, &net.OpError{}) { | |||
if _, ok := logErr.(*net.OpError); ok || errors.Is(logErr, &net.OpError{}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to add a test case for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I could have easily reproduced the problem I would have resolved this issue the first time and known that the original solution didn't work.
make lgtm work |
…2) (go-gitea#19049) Backport go-gitea#19049 Unfortunately go-gitea#18642 does not work because a `*net.OpError` does not implement the `Is` interface to make `errors.Is` work correctly - thus leading to the irritating conclusion that a `*net.OpError` is not a `*net.OpError`. Here we keep the `errors.Is` because presumably this will be fixed at some point in the golang main source code but also we add a simply type cast to also check. Fix go-gitea#18629 Signed-off-by: Andrew Thornton <art27@cantab.net>
…2) (#19049) (#19056) Backport #19049 Unfortunately #18642 does not work because a `*net.OpError` does not implement the `Is` interface to make `errors.Is` work correctly - thus leading to the irritating conclusion that a `*net.OpError` is not a `*net.OpError`. Here we keep the `errors.Is` because presumably this will be fixed at some point in the golang main source code but also we add a simply type cast to also check. Fix #18629 Signed-off-by: Andrew Thornton <art27@cantab.net>
* giteaofficial/main: Prevent 500 when there is an error during new auth source post (go-gitea#19041) Update the webauthn_credential_id_sequence in Postgres (go-gitea#19048) If rendering has failed due to a net.OpError stop rendering (attempt 2) (go-gitea#19049) use xorm builder for models.getReviewers() (go-gitea#19033) RSS/Atom support for Orgs (go-gitea#17714) Fix flag validation (go-gitea#19046) Improve SyncMirrors logging (go-gitea#19045)
…2) (go-gitea#19049) Unfortunately go-gitea#18642 does not work because a `*net.OpError` does not implement the `Is` interface to make `errors.Is` work correctly - thus leading to the irritating conclusion that a `*net.OpError` is not a `*net.OpError`. Here we keep the `errors.Is` because presumably this will be fixed at some point in the golang main source code but also we add a simply type cast to also check. Fix go-gitea#18629 Signed-off-by: Andrew Thornton <art27@cantab.net>
Unfortunately #18642 does not work because a
*net.OpError
does not implementthe
Is
interface to makeerrors.Is
work correctly - thus leading to theirritating conclusion that a
*net.OpError
is not a*net.OpError
.Here we keep the
errors.Is
because presumably this will be fixed atsome point in the golang main source code but also we add a simply type
cast to also check.
Fix #18629
Signed-off-by: Andrew Thornton art27@cantab.net