@@ -199,15 +199,38 @@ public class HTTPClient {
199
199
}
200
200
}
201
201
202
- public enum HTTPClientError : Error {
203
- case invalidURL
204
- case emptyHost
205
- case alreadyShutdown
206
- case emptyScheme
207
- case unsupportedScheme( String )
208
- case readTimeout
209
- case remoteConnectionClosed
210
- case cancelled
211
- case identityCodingIncorrectlyPresent
212
- case chunkedSpecifiedMultipleTimes
202
+ public struct HTTPClientError : Error , Equatable , CustomStringConvertible {
203
+ private enum Code : Equatable {
204
+ case invalidURL
205
+ case emptyHost
206
+ case alreadyShutdown
207
+ case emptyScheme
208
+ case unsupportedScheme( String )
209
+ case readTimeout
210
+ case remoteConnectionClosed
211
+ case cancelled
212
+ case identityCodingIncorrectlyPresent
213
+ case chunkedSpecifiedMultipleTimes
214
+ }
215
+
216
+ private var code : Code
217
+
218
+ private init ( code: Code ) {
219
+ self . code = code
220
+ }
221
+
222
+ public var description : String {
223
+ return " SandwichError. \( String ( describing: self . code) ) "
224
+ }
225
+
226
+ public static let invalidURL = HTTPClientError ( code: . invalidURL)
227
+ public static let emptyHost = HTTPClientError ( code: . emptyHost)
228
+ public static let alreadyShutdown = HTTPClientError ( code: . alreadyShutdown)
229
+ public static let emptyScheme = HTTPClientError ( code: . emptyScheme)
230
+ public static func unsupportedScheme( _ scheme: String ) -> HTTPClientError { return HTTPClientError ( code: . unsupportedScheme( scheme) ) }
231
+ public static let readTimeout = HTTPClientError ( code: . readTimeout)
232
+ public static let remoteConnectionClosed = HTTPClientError ( code: . remoteConnectionClosed)
233
+ public static let cancelled = HTTPClientError ( code: . cancelled)
234
+ public static let identityCodingIncorrectlyPresent = HTTPClientError ( code: . identityCodingIncorrectlyPresent)
235
+ public static let chunkedSpecifiedMultipleTimes = HTTPClientError ( code: . chunkedSpecifiedMultipleTimes)
213
236
}
0 commit comments