Skip to content

Commit 6cc76ec

Browse files
authored
feat: Improve ParseError reporting by propagating Swift.Error (#64)
* feat: Improve ParseError reporting by propagating Swift.Error * fix build on linux * fix flakey tests
1 parent 2410ff6 commit 6cc76ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+341
-389
lines changed

.codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ coverage:
66
status:
77
patch:
88
default:
9-
target: 82
9+
target: auto
1010
changes: false
1111
project:
1212
default:

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ deprecation warnings when building your app in Xcode before upgrading
3030
to [Corey Baker](https://github.com/cbaker6).
3131

3232
__New features__
33+
* ParseError now has a new property called "swift" which is of type Swift.Error. This property will not be nil when the ParseError is really an OS error. This is intented to help developers improve error handeling by propagating the complete error ([#64](https://github.com/netreconlab/Parse-Swift/pull/64)), thanks to [Corey Baker](https://github.com/cbaker6).
3334
* Add user login related attempts to ParseCloudUser. This allows developers to decode login related information when using Parse-Swift for Cloud Code ([#51](https://github.com/netreconlab/Parse-Swift/pull/51)), thanks to [Corey Baker](https://github.com/cbaker6).
3435
* Add option to set the serverURL for a particular call. This is useful when using the Swift SDK for Cloud Code in a multi-server environment ([#50](https://github.com/netreconlab/Parse-Swift/pull/50)), thanks to [Corey Baker](https://github.com/cbaker6).
3536
* ParseVersion now supports pre-release versions of the SDK ([#49](https://github.com/netreconlab/Parse-Swift/pull/49)), thanks to [Corey Baker](https://github.com/cbaker6).

Sources/ParseSwift/API/API+Command.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,7 @@ internal extension API.Command where T: ParseObject {
528528
return .success(updatedObject)
529529
} catch {
530530
guard let parseError = error as? ParseError else {
531-
return .failure(ParseError(code: .otherCause,
532-
message: error.localizedDescription))
531+
return .failure(ParseError(swift: error))
533532
}
534533
return .failure(parseError)
535534
}

Sources/ParseSwift/Authentication/3rd Party/ParseApple/ParseApple.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public extension ParseApple {
7575
guard let appleAuthData = try? AuthenticationKeys.id.makeDictionary(user: user, identityToken: identityToken) else {
7676
callbackQueue.async {
7777
completion(.failure(.init(code: .otherCause,
78-
message: "Could not create authData.")))
78+
message: "Could not create \"authData\".")))
7979
}
8080
return
8181
}
@@ -92,7 +92,7 @@ public extension ParseApple {
9292
guard AuthenticationKeys.id.verifyMandatoryKeys(authData: authData) else {
9393
callbackQueue.async {
9494
completion(.failure(.init(code: .otherCause,
95-
message: "Should have authData in consisting of keys \"id\" and \"token\".")))
95+
message: "Should have \"authData\" in consisting of keys \"id\" and \"token\".")))
9696
}
9797
return
9898
}
@@ -123,7 +123,7 @@ public extension ParseApple {
123123
guard let appleAuthData = try? AuthenticationKeys.id.makeDictionary(user: user, identityToken: identityToken) else {
124124
callbackQueue.async {
125125
completion(.failure(.init(code: .otherCause,
126-
message: "Could not create authData.")))
126+
message: "Could not create \"authData\".")))
127127
}
128128
return
129129
}
@@ -139,7 +139,7 @@ public extension ParseApple {
139139
completion: @escaping (Result<AuthenticatedUser, ParseError>) -> Void) {
140140
guard AuthenticationKeys.id.verifyMandatoryKeys(authData: authData) else {
141141
let error = ParseError(code: .otherCause,
142-
message: "Should have authData in consisting of keys \"id\" and \"token\".")
142+
message: "Should have \"authData\" in consisting of keys \"id\" and \"token\".")
143143
callbackQueue.async {
144144
completion(.failure(error))
145145
}

Sources/ParseSwift/Authentication/3rd Party/ParseFacebook/ParseFacebook.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public extension ParseFacebook {
137137
guard AuthenticationKeys.id.verifyMandatoryKeys(authData: authData) else {
138138
callbackQueue.async {
139139
completion(.failure(.init(code: .otherCause,
140-
message: "Should have authData in consisting of keys \"id\", \"expirationDate\" and \"authenticationToken\" or \"accessToken\".")))
140+
message: "Should have \"authData\" in consisting of keys \"id\", \"expirationDate\" and \"authenticationToken\" or \"accessToken\".")))
141141
}
142142
return
143143
}
@@ -211,7 +211,7 @@ public extension ParseFacebook {
211211
guard AuthenticationKeys.id.verifyMandatoryKeys(authData: authData) else {
212212
callbackQueue.async {
213213
completion(.failure(.init(code: .otherCause,
214-
message: "Should have authData in consisting of keys \"id\", \"expirationDate\" and \"authenticationToken\" or \"accessToken\".")))
214+
message: "Should have \"authData\" in consisting of keys \"id\", \"expirationDate\" and \"authenticationToken\" or \"accessToken\".")))
215215
}
216216
return
217217
}

Sources/ParseSwift/Authentication/3rd Party/ParseGithub/ParseGitHub.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public extension ParseGitHub {
8888
guard AuthenticationKeys.id.verifyMandatoryKeys(authData: authData) else {
8989
callbackQueue.async {
9090
completion(.failure(.init(code: .otherCause,
91-
message: "Should have authData in consisting of keys \"id\" and \"accessToken\".")))
91+
message: "Should have \"authData\" in consisting of keys \"id\" and \"accessToken\".")))
9292
}
9393
return
9494
}
@@ -132,7 +132,7 @@ public extension ParseGitHub {
132132
guard AuthenticationKeys.id.verifyMandatoryKeys(authData: authData) else {
133133
callbackQueue.async {
134134
completion(.failure(.init(code: .otherCause,
135-
message: "Should have authData in consisting of keys \"id\" and \"accessToken\".")))
135+
message: "Should have \"authData\" in consisting of keys \"id\" and \"accessToken\".")))
136136
}
137137
return
138138
}

Sources/ParseSwift/Authentication/3rd Party/ParseGoogle/ParseGoogle.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public extension ParseGoogle {
100100
guard AuthenticationKeys.id.verifyMandatoryKeys(authData: authData) else {
101101
callbackQueue.async {
102102
completion(.failure(.init(code: .otherCause,
103-
message: "Should have authData in consisting of keys \"id\", \"idToken\" or \"accessToken\".")))
103+
message: "Should have \"authData\" in consisting of keys \"id\", \"idToken\" or \"accessToken\".")))
104104
}
105105
return
106106
}
@@ -147,7 +147,7 @@ public extension ParseGoogle {
147147
guard AuthenticationKeys.id.verifyMandatoryKeys(authData: authData) else {
148148
callbackQueue.async {
149149
completion(.failure(.init(code: .otherCause,
150-
message: "Should have authData in consisting of keys \"id\", \"idToken\" or \"accessToken\".")))
150+
message: "Should have \"authData\" in consisting of keys \"id\", \"idToken\" or \"accessToken\".")))
151151
}
152152
return
153153
}

Sources/ParseSwift/Authentication/3rd Party/ParseInstagram/ParseInstagram.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public extension ParseInstagram {
9999
guard AuthenticationKeys.id.verifyMandatoryKeys(authData: authData) else {
100100
callbackQueue.async {
101101
completion(.failure(.init(code: .otherCause,
102-
message: "Should have authData in consisting of keys \"id\", \"accessToken\", and \"isMobileSDK\".")))
102+
message: "Should have \"authData\" in consisting of keys \"id\", \"accessToken\", and \"isMobileSDK\".")))
103103
}
104104
return
105105
}
@@ -146,7 +146,7 @@ public extension ParseInstagram {
146146
guard AuthenticationKeys.id.verifyMandatoryKeys(authData: authData) else {
147147
callbackQueue.async {
148148
completion(.failure(.init(code: .otherCause,
149-
message: "Should have authData in consisting of keys \"id\", \"accessToken\", and \"isMobileSDK\".")))
149+
message: "Should have \"authData\" in consisting of keys \"id\", \"accessToken\", and \"isMobileSDK\".")))
150150
}
151151
return
152152
}

Sources/ParseSwift/Authentication/3rd Party/ParseLDAP/ParseLDAP.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public extension ParseLDAP {
7979
guard AuthenticationKeys.id.verifyMandatoryKeys(authData: authData) else {
8080
callbackQueue.async {
8181
completion(.failure(.init(code: .otherCause,
82-
message: "Should have authData in consisting of keys \"id\" and \"password\".")))
82+
message: "Should have \"authData\" in consisting of keys \"id\" and \"password\".")))
8383
}
8484
return
8585
}
@@ -119,7 +119,7 @@ public extension ParseLDAP {
119119
completion: @escaping (Result<AuthenticatedUser, ParseError>) -> Void) {
120120
guard AuthenticationKeys.id.verifyMandatoryKeys(authData: authData) else {
121121
let error = ParseError(code: .otherCause,
122-
message: "Should have authData in consisting of keys \"id\" and \"password\".")
122+
message: "Should have \"authData\" in consisting of keys \"id\" and \"password\".")
123123
callbackQueue.async {
124124
completion(.failure(error))
125125
}

Sources/ParseSwift/Authentication/3rd Party/ParseLinkedIn/ParseLinkedIn.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public extension ParseLinkedIn {
9494
guard AuthenticationKeys.id.verifyMandatoryKeys(authData: authData) else {
9595
callbackQueue.async {
9696
completion(.failure(.init(code: .otherCause,
97-
message: "Should have authData in consisting of keys \"id\", \"accessToken\", and \"isMobileSDK\".")))
97+
message: "Should have \"authData\" in consisting of keys \"id\", \"accessToken\", and \"isMobileSDK\".")))
9898
}
9999
return
100100
}
@@ -140,7 +140,7 @@ public extension ParseLinkedIn {
140140
guard AuthenticationKeys.id.verifyMandatoryKeys(authData: authData) else {
141141
callbackQueue.async {
142142
completion(.failure(.init(code: .otherCause,
143-
message: "Should have authData in consisting of keys \"id\", \"accessToken\", and \"isMobileSDK\".")))
143+
message: "Should have \"authData\" in consisting of keys \"id\", \"accessToken\", and \"isMobileSDK\".")))
144144
}
145145
return
146146
}

0 commit comments

Comments
 (0)