Skip to content

Commit 81488d4

Browse files
committed
Pass the original error when creating a cart.
1 parent f23c6a5 commit 81488d4

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

Yosemite/Yosemite/Stores/PaymentStore.swift

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private extension PaymentStore {
7070
_ = try await remote.createCart(siteID: siteID, productID: productID)
7171
completion(.success(()))
7272
} catch {
73-
completion(.failure(CreateCartError(remoteError: error)))
73+
completion(.failure(error))
7474
}
7575
}
7676
}
@@ -80,17 +80,4 @@ private extension PaymentStore {
8080
public enum CreateCartError: Error, Equatable {
8181
/// Product ID is not in the correct format for WPCOM plans.
8282
case invalidProductID
83-
/// Unexpected error from WPCOM.
84-
case unexpected(error: DotcomError)
85-
/// Unknown error that is not a `DotcomError`.
86-
case unknown(description: String)
87-
88-
init(remoteError: Error) {
89-
switch remoteError {
90-
case let remoteError as DotcomError:
91-
self = .unexpected(error: remoteError)
92-
default:
93-
self = .unknown(description: remoteError.localizedDescription)
94-
}
95-
}
9683
}

Yosemite/YosemiteTests/Stores/PaymentStoreTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,7 @@ final class PaymentStoreTests: XCTestCase {
117117

118118
// Then
119119
XCTAssertTrue(result.isFailure)
120+
let error = try XCTUnwrap(result.failure)
121+
XCTAssertEqual(error as? NetworkError, .timeout)
120122
}
121123
}

0 commit comments

Comments
 (0)