@@ -11,82 +11,6 @@ import NIOHTTP1
11
11
import NIOFoundationCompat
12
12
import AsyncHTTPClient
13
13
14
- /// An enumeration representing the various errors that can occur when interacting with CouchDB through a client.
15
- /// This enum conforms to both `Error` and `Sendable`, making it suitable for error handling and thread-safe operations.
16
- public enum CouchDBClientError : Error , Sendable {
17
- /// The `id` property is empty or missing in the provided document.
18
- /// This error indicates that the document does not have a valid identifier.
19
- case idMissing
20
-
21
- /// The `_rev` property is empty or missing in the provided document.
22
- /// This error indicates that the document does not have a valid revision token for concurrency control.
23
- case revMissing
24
-
25
- /// The `GET` request was unsuccessful.
26
- /// - Parameter error: The `CouchDBError` returned by the server, providing details about the issue.
27
- case getError( error: CouchDBError )
28
-
29
- /// The `INSERT` request was unsuccessful.
30
- /// - Parameter error: The `CouchDBError` returned by the server, providing details about the issue.
31
- case insertError( error: CouchDBError )
32
-
33
- /// The `DELETE` request was unsuccessful.
34
- /// - Parameter error: The `CouchDBError` returned by the server, providing details about the issue.
35
- case deleteError( error: CouchDBError )
36
-
37
- /// The `UPDATE` request was unsuccessful.
38
- /// - Parameter error: The `CouchDBError` returned by the server, providing details about the issue.
39
- case updateError( error: CouchDBError )
40
-
41
- /// The `FIND` request was unsuccessful.
42
- /// - Parameter error: The `CouchDBError` returned by the server, providing details about the issue.
43
- case findError( error: CouchDBError )
44
-
45
- /// The response from CouchDB was unrecognized or could not be processed.
46
- /// This error indicates that the response was not in the expected format.
47
- case unknownResponse
48
-
49
- /// Authentication failed due to incorrect username or password.
50
- /// This error suggests that the provided credentials were invalid.
51
- case unauthorized
52
-
53
- /// The response body is missing required data.
54
- /// This error indicates that the server response lacked the expected content.
55
- case noData
56
- }
57
-
58
- /// Extends the `CouchDBClientError` enumeration to provide localized error descriptions.
59
- /// This extension conforms to the `LocalizedError` protocol, offering user-friendly messages
60
- /// that describe the nature of each error in detail.
61
- extension CouchDBClientError : LocalizedError {
62
- /// A textual description of the error, tailored for user-facing contexts.
63
- /// The message provides specific details about the error type and underlying cause.
64
- public var errorDescription : String ? {
65
- switch self {
66
- case . idMissing:
67
- return " The 'id' property is empty or missing in the provided document. "
68
- case . revMissing:
69
- return " The '_rev' property is empty or missing in the provided document. "
70
- case . getError( let error) :
71
- return " The GET request wasn't successful: \( error. localizedDescription) "
72
- case . insertError( let error) :
73
- return " The INSERT request wasn't successful: \( error. localizedDescription) "
74
- case . updateError( let error) :
75
- return " The UPDATE request wasn't successful: \( error. localizedDescription) "
76
- case . deleteError( let error) :
77
- return " The DELETE request wasn't successful: \( error. localizedDescription) "
78
- case . findError( let error) :
79
- return " The FIND request wasn't successful: \( error. localizedDescription) "
80
- case . unknownResponse:
81
- return " The response from CouchDB was unrecognized or invalid. "
82
- case . unauthorized:
83
- return " Authentication failed due to an incorrect username or password. "
84
- case . noData:
85
- return " The response body is missing the expected data. "
86
- }
87
- }
88
- }
89
-
90
14
/// A CouchDB client actor with methods using Swift Concurrency.
91
15
public actor CouchDBClient {
92
16
/// A configuration model for CouchDB client setup.
0 commit comments