Skip to content

Commit 91d4075

Browse files
author
Gusted
committed
Merge pull request '[FEAT] Don't log context cancelled SQL errors (squash)' (go-gitea#2330) from gusted/forgejo-no-db into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2330 Reviewed-by: Otto <[email protected]>
2 parents c6a89b4 + cbbcfdd commit 91d4075

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

models/db/engine.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package db
77
import (
88
"context"
99
"database/sql"
10+
"errors"
1011
"fmt"
1112
"io"
1213
"reflect"
@@ -342,7 +343,7 @@ func (ErrorQueryHook) BeforeProcess(c *contexts.ContextHook) (context.Context, e
342343
}
343344

344345
func (h *ErrorQueryHook) AfterProcess(c *contexts.ContextHook) error {
345-
if c.Err != nil {
346+
if c.Err != nil && !errors.Is(c.Err, context.Canceled) {
346347
h.Logger.Log(8, log.ERROR, "[Error SQL Query] %s %v - %v", c.SQL, c.Args, c.Err)
347348
}
348349
return nil

0 commit comments

Comments
 (0)