Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit 3eaf8f8

Browse files
committed
Return always an error
1 parent 1a8f226 commit 3eaf8f8

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

WordPressKit/JetpackServiceRemote.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public struct JetpackInstallError: LocalizedError, Equatable {
2626
return JetpackInstallError(type: .unknown)
2727
}
2828

29-
public init(title: String? = nil, code: Int = 0, key: String) {
30-
self.init(title: title, code: code, type: ErrorType(error: key))
29+
public init(title: String? = nil, code: Int = 0, key: String? = nil) {
30+
self.init(title: title, code: code, type: ErrorType(error: key ?? ""))
3131
}
3232

3333
public init(title: String? = nil, code: Int = 0, type: ErrorType = .unknown) {
@@ -84,11 +84,11 @@ public class JetpackServiceRemote: ServiceRemoteWordPressComREST {
8484
completion(false, JetpackInstallError(type: .installResponseError))
8585
}
8686
}) { (error: NSError, httpResponse: HTTPURLResponse?) in
87-
if let key = error.userInfo[WordPressComRestApi.ErrorKeyErrorCode] as? String {
88-
completion(false, JetpackInstallError(title: error.localizedDescription, code: error.code, key: key))
89-
} else {
90-
completion(false, .unknown)
91-
}
87+
let key = error.userInfo[WordPressComRestApi.ErrorKeyErrorCode] as? String
88+
let jetpackError = JetpackInstallError(title: error.localizedDescription,
89+
code: error.code,
90+
key: key)
91+
completion(false, jetpackError)
9292
}
9393
}
9494

0 commit comments

Comments
 (0)