File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed
stdlib/public/SDK/Foundation Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -135,6 +135,13 @@ public extension ErrorProtocol where Self : CustomNSError {
135
135
var _code : Int { return self . errorCode }
136
136
}
137
137
138
+ public extension ErrorProtocol {
139
+ /// Retrieve the localized description for this error.
140
+ var localizedDescription : String {
141
+ return ( self as! NSError ) . localizedDescription
142
+ }
143
+ }
144
+
138
145
/// Retrieve the default userInfo dictionary for a given error.
139
146
@_silgen_name ( " swift_Foundation_getErrorDefaultUserInfo " )
140
147
public func _swift_Foundation_getErrorDefaultUserInfo( _ error: ErrorProtocol )
Original file line number Diff line number Diff line change @@ -417,6 +417,8 @@ ErrorProtocolBridgingTests.test("Customizing NSError via protocols") {
417
417
nsError. userInfo [ NSLocalizedRecoverySuggestionErrorKey] as? String )
418
418
expectOptionalEqual ( " there is no help when writing tests " ,
419
419
nsError. userInfo [ NSHelpAnchorErrorKey] as? String )
420
+ expectEqual ( nsError. localizedDescription, " something went horribly wrong " )
421
+ expectEqual ( error. localizedDescription, " something went horribly wrong " )
420
422
421
423
// RecoverableError
422
424
expectOptionalEqual ( [ " Delete 'throw' " , " Disable the test " ] ,
You can’t perform that action at this time.
0 commit comments