diff --git a/Sources/NIOCore/Channel.swift b/Sources/NIOCore/Channel.swift index 9793102d5ea..73ed9362e42 100644 --- a/Sources/NIOCore/Channel.swift +++ b/Sources/NIOCore/Channel.swift @@ -427,6 +427,47 @@ extension ChannelError { extension ChannelError: Equatable {} +extension ChannelError: CustomStringConvertible { + public var description: String { + switch self { + case .connectPending: + "Connect pending" + case let .connectTimeout(value): + "Connect timeout (\(value))" + case .operationUnsupported: + "Operation unsupported" + case .ioOnClosedChannel: + "I/O on closed channel" + case .alreadyClosed: + "Already closed" + case .outputClosed: + "Output closed" + case .inputClosed: + "Input closed" + case .eof: + "End of file" + case .writeMessageTooLarge: + "Write message too large" + case .writeHostUnreachable: + "Write host unreachable" + case .unknownLocalAddress: + "Unknown local address" + case .badMulticastGroupAddressFamily: + "Bad multicast group address family" + case .badInterfaceAddressFamily: + "Bad interface address family" + case let .illegalMulticastAddress(address): + "Illegal multicast address \(address)" + case let .multicastNotSupported(interface): + "Multicast not supported on interface \(interface)" + case .inappropriateOperationForState: + "Inappropriate operation for state" + case .unremovableHandler: + "Unremovable handler" + } + } +} + /// The removal of a `ChannelHandler` using `ChannelPipeline.removeHandler` has been attempted more than once. public struct NIOAttemptedToRemoveHandlerMultipleTimesError: Error {} diff --git a/Sources/NIOPosix/HappyEyeballs.swift b/Sources/NIOPosix/HappyEyeballs.swift index f1d2e9e3e30..0e694e8c11f 100644 --- a/Sources/NIOPosix/HappyEyeballs.swift +++ b/Sources/NIOPosix/HappyEyeballs.swift @@ -70,6 +70,24 @@ public struct NIOConnectionError: Error { } } +extension NIOConnectionError: CustomStringConvertible { + public var description: String { + if let dnsError = (self.dnsAError ?? self.dnsAAAAError) { + return "DNS error: \(dnsError)" + } + + if !self.connectionErrors.isEmpty { + let descriptions = self.connectionErrors.map { + String(describing: $0) + } + + return "Connection errors: \(descriptions.joined(separator: ", "))" + } + + return "NIOConnectionError: unknown" + } +} + /// A simple iterator that manages iterating over the possible targets. /// /// This iterator knows how to merge together the A and AAAA records in a sensible way: