Merge pull request #1186 from benrb/databaseerror-message

DatabaseError provide error message as localizedFailureReason
This commit is contained in:
Gwendal Roué authored and GitHub committed 2022-03-22 08:26:14 +01:00
commit fb3e08aba8
2 files changed
+8 -1

No files matched your search

+7 -1
View File
@@ -506,5 +506,11 @@ extension DatabaseError {
/// NSError bridging: the user-info dictionary.
/// :nodoc:
public var errorUserInfo: [String: Any] { [NSLocalizedDescriptionKey: description] }
public var errorUserInfo: [String: Any] {
var userInfo = [NSLocalizedDescriptionKey: description]
if let message = message {
userInfo[NSLocalizedFailureReasonErrorKey] = message
}
return userInfo
}
}
+1
View File
@@ -226,6 +226,7 @@ class DatabaseErrorTests: GRDBTestCase {
XCTAssertEqual(DatabaseError.errorDomain, "GRDB.DatabaseError")
XCTAssertEqual(error.domain, DatabaseError.errorDomain)
XCTAssertEqual(error.code, 787)
XCTAssertNotNil(error.localizedFailureReason)
}
}
}