Skip to content

Commit

Permalink
Check for all 2xx response status code
Browse files Browse the repository at this point in the history
  • Loading branch information
fpseverino committed Sep 20, 2024
1 parent e281fe1 commit a87da0d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/SendGridKit/SendGridClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public struct SendGridClient: Sendable {
let response = try await httpClient.execute(request, timeout: .seconds(30))

// If the request was accepted, simply return
if response.status == .ok || response.status == .accepted { return }
if (200...299).contains(response.status.code) { return }

// JSONDecoder will handle empty body by throwing decoding error
throw try await decoder.decode(SendGridError.self, from: response.body.collect(upTo: 1024 * 1024))
Expand Down

0 comments on commit a87da0d

Please sign in to comment.