Skip to content

Commit 3a08807

Browse files
committed
Add HTTPClientError shortDescription property
This adds a shortDescription property to HTTPClientError which provides a short description of the error without associated values.
1 parent 13e93d4 commit 3a08807

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

Sources/AsyncHTTPClient/HTTPClient.swift

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,73 @@ public struct HTTPClientError: Error, Equatable, CustomStringConvertible {
949949
return "HTTPClientError.\(String(describing: self.code))"
950950
}
951951

952+
public var shortDescription: String {
953+
switch self.code {
954+
case .invalidURL:
955+
return "Invalid URL"
956+
case .emptyHost:
957+
return "Empty host"
958+
case .missingSocketPath:
959+
return "Missing socket path"
960+
case .alreadyShutdown:
961+
return "Already shutdown"
962+
case .emptyScheme:
963+
return "Empty scheme"
964+
case .unsupportedScheme:
965+
return "Unsupported scheme"
966+
case .readTimeout:
967+
return "Read timeout"
968+
case .remoteConnectionClosed:
969+
return "Remote connection closed"
970+
case .cancelled:
971+
return "Cancelled"
972+
case .identityCodingIncorrectlyPresent:
973+
return "Identity coding incorrectly present"
974+
case .chunkedSpecifiedMultipleTimes:
975+
return "Chunked specified multiple times"
976+
case .invalidProxyResponse:
977+
return "Invalid proxy response"
978+
case .contentLengthMissing:
979+
return "Content length missing"
980+
case .proxyAuthenticationRequired:
981+
return "Proxy authentication required"
982+
case .redirectLimitReached:
983+
return "Redirect limit reached"
984+
case .redirectCycleDetected:
985+
return "Redirect cycle detected"
986+
case .uncleanShutdown:
987+
return "Unclean shutdown"
988+
case .traceRequestWithBody:
989+
return "Trace request with body"
990+
case .invalidHeaderFieldNames:
991+
return "Invalid header field names"
992+
case .bodyLengthMismatch:
993+
return "Body length mismatch"
994+
case .writeAfterRequestSent:
995+
return "Write after request sent"
996+
case .incompatibleHeaders:
997+
return "Incompatible headers"
998+
case .connectTimeout:
999+
return "Connect timeout"
1000+
case .socksHandshakeTimeout:
1001+
return "SOCKS handshake timeout"
1002+
case .httpProxyHandshakeTimeout:
1003+
return "HTTP proxy handshake timeout"
1004+
case .tlsHandshakeTimeout:
1005+
return "TLS handshake timeout"
1006+
case .serverOfferedUnsupportedApplicationProtocol:
1007+
return "Server offered unsupported application protocol"
1008+
case .requestStreamCancelled:
1009+
return "Request stream cancelled"
1010+
case .getConnectionFromPoolTimeout:
1011+
return "Get connection from pool timeout"
1012+
case .deadlineExceeded:
1013+
return "Deadline exceeded"
1014+
case .httpEndReceivedAfterHeadWith1xx:
1015+
return "HTTP end received after head with 1xx"
1016+
}
1017+
}
1018+
9521019
/// URL provided is invalid.
9531020
public static let invalidURL = HTTPClientError(code: .invalidURL)
9541021
/// URL does not contain host.

0 commit comments

Comments
 (0)