MCPcopy Index your code
hub / github.com/coder/coder / isQueryCanceledError

Function isQueryCanceledError

testutil/logger.go:47–55  ·  view source on GitHub ↗

isQueryCanceledError checks if the error is due to a query being canceled. This reproduces database.IsQueryCanceledError, but is reimplemented here to avoid importing the database package, which would result in import loops. We also use string matching on the error PostgreSQL returns to us, rather t

(err error)

Source from the content-addressed store, hash-verified

45// to us, rather than the pq error type, because we don't want testutil, which is imported in lots
46// of places to import lib/pq, which we have our own fork of.
47func isQueryCanceledError(err error) bool {
48 if xerrors.Is(err, context.Canceled) || xerrors.Is(err, context.DeadlineExceeded) {
49 return true
50 }
51 if strings.Contains(err.Error(), "canceling statement due to user request") {
52 return true
53 }
54 return false
55}
56
57type testLogWriter struct {
58 t testing.TB

Callers 1

IgnoreLoggedErrorFunction · 0.85

Calls 3

IsMethod · 0.45
ContainsMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected