Skip to content

Commit 1bc01cd

Browse files
makonigevartosky
andauthored
2.2.0 (#33)
* swift-docc-plugin 1.3.0 * async-http-client 1.19.0 * replaced deprecated .createNew with the new .singleton * Adding _find capability. (#13) * docs * tabs * renames * added test for find method with body * docs added * findError added * tests renamed * added test for find method with generic type * docs * README updated * updated dependencies * docs updated * try Swift 5.7.1 * Update build-ubuntu.yml * Swift 5.7.3 * Revert "Swift 5.7.3" This reverts commit ab8f67a. * updated dependencies * Docs updated * Delete .github/workflows/CodeQL.yml * dependencies updated * fixed when update method didn’t use passed dateEncodingStrategy * noData error added * migrating to new HTTPClientRequest from HTTPClient.Request wip * migrating to new HTTPClientRequest from HTTPClient.Request wip * migrating to new HTTPClientRequest from HTTPClient.Request wip * migrating to new HTTPClientRequest from HTTPClient.Request wip * migrating to new HTTPClientRequest from HTTPClient.Request wip * migrating to new HTTPClientRequest from HTTPClient.Request wip * … * migrating to new HTTPClientRequest from HTTPClient.Request wip * rename * tests updated * auth fixed * collect body bytes before returning response * param renamed to make keep backward compatibility with old methods * marking old find as deprecated * private * deprecated message * renames * moved deprecations * docs * docs * added Codable to CouchDBRepresentable protocol * added RowsResponse model * docs * Vapor tutorial updated * docs * docs and refactoring * docs and refactoring * Tutorials updated * docs * platforms list updated * minimum swift version 5.8 * workflow updated * Update build-ubuntu.yml * Update build-macos.yml * import NIOFoundationCompat to fix building on Ubuntu * using async-http-client from 1.21.0. Not calling http * Using HTTPClient.shared if eventLoopGroup not provided. No more calls httpClient.syncShutdown() if using shared singleton * docs updated * docs updated * Vapor tutorial updated * A SwiftUI tutorial * tutorial fixed * updated dependencies * Package.resolved * docs updated * userName param is now required for CouchDB init * cleanup * docs * docs * docs * docs * docs * docs * docs * docs * docs * docs * docs * docs * docs * docs * docs * docs * dependencices updated * updated swift-docc-plugin URL. Updated dependencies to latest versions. * Update build-ubuntu.yml * dependencies updated * deleted deprecated methods * Sendable conformance * swift-format added * formatting * formatting * revert sendable * updated dependencies * Sensable conformance * updated CouchDBRepresentable protocol * Sendable conformance * Strict concurrency implemented * Swift 6 * docs updated * errors and docs * docs * docs * docs wip * docs * wip * wip * docs * docs * get only _rev * tutorials updated * docs * Update README.md * Update README.md * updated GitHub actions configs * dependencies updated * updated docs * code formatting * refactoring * localized error messages * Added error messages translations * More translations * fixes for Linux * docs * create HTTPClient if not provided in init * new test added * use FoundationEssentials if possible * tests updated * dependencies updated * added shutdown method * formatting * added tutorial for Hummingbird * tutorials * tutorial * tutorials * docs * renamed couchdb-vapor to couchdb-swift * docs * try to use FoundationEssentials everywhere and Dispatch * removed FoundationEssentials usage, can’t use Bundle with it * dependencies updated * dependencies * dependencies updated * added new conflictError error * handle conflict error in Update method * Added missing authorization for delete document request * tabs * tabs * added handling of not found error in update method * added handling of not found error in delete method * added more tests * translations for CONFLICT_ERROR * fixed date format * Percent-encode username and password * updated config * updated actions configs * notFound error added * Throw .notFound error for get requests * translations --------- Co-authored-by: Gregório Gevartosky Torrezan <[email protected]>
1 parent 382c797 commit 1bc01cd

File tree

4 files changed

+2988
-2704
lines changed

4 files changed

+2988
-2704
lines changed

Sources/CouchDBClient/CouchDBClient.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,19 @@ public actor CouchDBClient {
537537
let body = response.body
538538
let expectedBytes = response.headers.first(name: "content-length").flatMap(Int.init) ?? 1024 * 1024 * 10
539539

540+
if response.status == .notFound {
541+
var bytes = try await body.collect(upTo: expectedBytes)
542+
guard let data = bytes.readData(length: bytes.readableBytes) else {
543+
throw CouchDBClientError.noData
544+
}
545+
546+
let decoder = JSONDecoder()
547+
if let couchdbError = try? decoder.decode(CouchDBError.self, from: data) {
548+
throw CouchDBClientError.notFound(error: couchdbError)
549+
}
550+
throw CouchDBClientError.unknownResponse
551+
}
552+
540553
response.body = .bytes(
541554
try await body.collect(upTo: expectedBytes)
542555
)

0 commit comments

Comments
 (0)