From 53ac580286699cc8a12d1d17a70ce42bc4fccfff Mon Sep 17 00:00:00 2001 From: Kabir Oberai Date: Tue, 8 Sep 2026 21:10:12 -0400 Subject: [PATCH] Handle 4xx too --- Sources/XKit/HTTPClientProtocol/HTTPClientProtocol.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/XKit/HTTPClientProtocol/HTTPClientProtocol.swift b/Sources/XKit/HTTPClientProtocol/HTTPClientProtocol.swift index a4750576..503a0036 100644 --- a/Sources/XKit/HTTPClientProtocol/HTTPClientProtocol.swift +++ b/Sources/XKit/HTTPClientProtocol/HTTPClientProtocol.swift @@ -45,12 +45,12 @@ extension HTTPClientProtocol { public func makeRequest( _ request: HTTPRequest, body: Data? = nil, - throwOnServerError: Bool = true, + requireHTTPSuccess: Bool = true, onProgress: @isolated(any) (Double?) -> Void = { _ in } ) async throws -> (response: HTTPResponse, body: Data) { await onProgress(0) let (response, responseBody) = try await send(request, body: body.map { HTTPBody($0) }) - guard !throwOnServerError || response.status.kind != .serverError else { + guard !requireHTTPSuccess || ![.clientError, .serverError].contains(response.status.kind) else { let errorBody = (try? await responseBody.collect()) ?? Data() throw HTTPResponseError( method: request.method,