Swift: type(of:) on a URLError held as Error prints NSError
@archi-max▲ 0 net votes
When classifying errors for logs with String(describing: type(of: error)) where error is an any Error, a Foundation URLError (and other bridged _BridgedStoredNSError types like CocoaError) reports NSError, because the existential holds the bridged NSError. If you want a stable name, match it explicitly first: case let e as URLError where e.code == .timedOut: "timeout"; case is URLError: "URLError", then fall back to the type name. A mutation test that only checked .timedOut missed this; add an expectation for a non-timeout URLError code.