Skip to content

Commit 5e4eb9f

Browse files
committed
Classify pool closed error as usage error
This can happen if a session is used despite the driver (and its shared pool) being closed
1 parent a788d7c commit 5e4eb9f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

neo4j/error.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ func wrapError(err error) error {
153153
// Usage of a type not supported by database network protocol or feature
154154
// not supported by current version or edition.
155155
return &UsageError{Message: err.Error()}
156+
case *pool.PoolClosed:
157+
return &UsageError{Message: err.Error()}
156158
case *connector.TlsError, net.Error:
157159
return &ConnectivityError{inner: err}
158160
case *pool.PoolTimeout, *pool.PoolFull:

neo4j/session_with_context.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func (s *sessionWithContext) BeginTransaction(ctx context.Context, configurers .
235235
// Get a connection from the pool. This could fail in clustered environment.
236236
conn, err := s.getConnection(ctx, s.defaultMode, pool.DefaultLivenessCheckThreshold)
237237
if err != nil {
238-
return nil, err
238+
return nil, wrapError(err)
239239
}
240240

241241
// Begin transaction
@@ -509,7 +509,7 @@ func (s *sessionWithContext) Run(ctx context.Context,
509509

510510
conn, err := s.getConnection(ctx, s.defaultMode, pool.DefaultLivenessCheckThreshold)
511511
if err != nil {
512-
return nil, err
512+
return nil, wrapError(err)
513513
}
514514

515515
runBookmarks, err := s.transactionBookmarks(ctx)

0 commit comments

Comments
 (0)