Skip to content

Commit 951f353

Browse files
Merge pull request #5065 from apple/debuggable-nserrors
Include userInfo in Error descriptions
2 parents e1d7356 + c09a4f7 commit 951f353

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Sources/Foundation/NSError.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,11 @@ open class NSError : NSObject, NSCopying, NSSecureCoding, NSCoding, @unchecked S
182182
}
183183

184184
override open var description: String {
185-
return "Error Domain=\(domain) Code=\(code) \"\(localizedFailureReason ?? "(null)")\""
185+
var result = "Error Domain=\(domain) Code=\(code) \"\(localizedFailureReason ?? "(null)")\""
186+
if !userInfo.isEmpty {
187+
result += "UserInfo={\(userInfo.map { "\($0)=\($1)"}.joined(separator: ", "))}"
188+
}
189+
return result
186190
}
187191

188192
// -- NSObject Overrides --

0 commit comments

Comments
 (0)