Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions Sources/NIOCore/Channel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

Expand Down
18 changes: 18 additions & 0 deletions Sources/NIOPosix/HappyEyeballs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading