Skip to content

Commit e2a6bce

Browse files
committed
Log errors during connection.close()
1 parent 42e9e0b commit e2a6bce

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Sources/PostgresConnectionPool/PostgresConnectionPool.swift

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,12 @@ public actor PostgresConnectionPool {
154154
}
155155
}
156156

157-
try? await connection.close()
157+
do {
158+
try await connection.close()
159+
}
160+
catch {
161+
logger.warning("[\(poolName)] connection.close() error: \(error)")
162+
}
158163
}
159164
}
160165
connections.removeAll()
@@ -212,9 +217,9 @@ public actor PostgresConnectionPool {
212217
return
213218
}
214219

215-
do {
216-
poolConnection.state = .active(Date())
220+
poolConnection.state = .active(Date())
217221

222+
do {
218223
// Connection check, etc.
219224
if let onReturnConnection = onReturnConnection {
220225
try await onReturnConnection(connection, logger)
@@ -237,7 +242,12 @@ public actor PostgresConnectionPool {
237242
}
238243
}
239244

240-
try? await connection.close()
245+
do {
246+
try await connection.close()
247+
}
248+
catch {
249+
logger.warning("[\(poolName)] connection.close() error: \(error)")
250+
}
241251
}
242252
}
243253
}

0 commit comments

Comments
 (0)