Skip to content

Commit

Permalink
Classify pool closed error as usage error
Browse files Browse the repository at this point in the history
This can happen if a session is used despite the driver (and its
shared pool) being closed
  • Loading branch information
fbiville committed Sep 8, 2022
1 parent a788d7c commit 5e4eb9f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions neo4j/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ func wrapError(err error) error {
// Usage of a type not supported by database network protocol or feature
// not supported by current version or edition.
return &UsageError{Message: err.Error()}
case *pool.PoolClosed:
return &UsageError{Message: err.Error()}
case *connector.TlsError, net.Error:
return &ConnectivityError{inner: err}
case *pool.PoolTimeout, *pool.PoolFull:
Expand Down
4 changes: 2 additions & 2 deletions neo4j/session_with_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (s *sessionWithContext) BeginTransaction(ctx context.Context, configurers .
// Get a connection from the pool. This could fail in clustered environment.
conn, err := s.getConnection(ctx, s.defaultMode, pool.DefaultLivenessCheckThreshold)
if err != nil {
return nil, err
return nil, wrapError(err)
}

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

conn, err := s.getConnection(ctx, s.defaultMode, pool.DefaultLivenessCheckThreshold)
if err != nil {
return nil, err
return nil, wrapError(err)
}

runBookmarks, err := s.transactionBookmarks(ctx)
Expand Down

0 comments on commit 5e4eb9f

Please sign in to comment.