Skip to content

Commit fa61e36

Browse files
committed
Comment, don't return error for unrecognised decode error
1 parent 770e2e2 commit fa61e36

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Sources/JobsPostgres/PostgresJobsQueue.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ public final class PostgresJobQueue: JobQueueDriver {
234234

235235
func popFirst() async throws -> JobQueueResult<JobID>? {
236236
do {
237+
// The withTransaction closure returns a Result<JobQueueResult<JobID>?, Error> because
238+
// we want to be able to exit the closure without cancelling the transaction
237239
let result = try await self.client.withTransaction(logger: self.logger) { connection -> Result<JobQueueResult<JobID>?, Error> in
238240
while true {
239241
try Task.checkCancellation()
@@ -269,7 +271,7 @@ public final class PostgresJobQueue: JobQueueDriver {
269271
do {
270272
guard let buffer = try await stream2.decode(ByteBuffer.self, context: .default).first(where: { _ in true }) else {
271273
logger.error(
272-
"Failed to job with id",
274+
"Failed to find job with id",
273275
metadata: [
274276
"JobID": "\(jobID)"
275277
]
@@ -283,10 +285,6 @@ public final class PostgresJobQueue: JobQueueDriver {
283285
return Result.success(.init(id: jobID, result: .success(jobInstance)))
284286
} catch let error as JobQueueError {
285287
return Result.success(.init(id: jobID, result: .failure(error)))
286-
} catch {
287-
return Result.success(
288-
.init(id: jobID, result: .failure(JobQueueError(code: .unrecognised, jobName: nil, details: "\(error)")))
289-
)
290288
}
291289
} catch {
292290
try await self.setStatus(jobID: jobID, status: .failed, connection: connection)

0 commit comments

Comments
 (0)