diff --git a/CHANGELOG.md b/CHANGELOG.md index 62319223..60243521 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,7 +34,7 @@ _None._ ### Breaking Changes -- The Objective-C-visible `WordPressOrgXMLRPCError` `enum` has been renamed to `WordPressOrgXMLRPCErrorCode` [#790] +- The Objective-C-visible `WordPressOrgXMLRPCError` `enum` has been renamed to `WordPressOrgXMLRPCErrorCode`, `WordPressOrgXMLRPCError.Code` in Swift [#790] ### New Features diff --git a/Sources/CoreAPI/WordPressOrgXMLRPCApiError.swift b/Sources/CoreAPI/WordPressOrgXMLRPCApiError.swift index c359c061..946b4a37 100644 --- a/Sources/CoreAPI/WordPressOrgXMLRPCApiError.swift +++ b/Sources/CoreAPI/WordPressOrgXMLRPCApiError.swift @@ -1,19 +1,20 @@ import Foundation -/// Error constants for the WordPress XML-RPC API -@objc public enum WordPressOrgXMLRPCApiErrorCode: Int, CaseIterable { - /// An error HTTP status code was returned. - case httpErrorStatusCode - /// The serialization of the request failed. - case requestSerializationFailed - /// The serialization of the response failed. - case responseSerializationFailed - /// An unknown error occurred. - case unknown -} - public struct WordPressOrgXMLRPCApiError: Error { - let code: WordPressOrgXMLRPCApiErrorCode + + /// Error constants for the WordPress XML-RPC API + @objc public enum Code: Int, CaseIterable { + /// An error HTTP status code was returned. + case httpErrorStatusCode + /// The serialization of the request failed. + case requestSerializationFailed + /// The serialization of the response failed. + case responseSerializationFailed + /// An unknown error occurred. + case unknown + } + + let code: Code } extension WordPressOrgXMLRPCApiError: LocalizedError { diff --git a/Tests/CoreAPITests/WordPressOrgXMLRPCApiErrorTests.swift b/Tests/CoreAPITests/WordPressOrgXMLRPCApiErrorTests.swift index 03b0e61a..8a6d0f9a 100644 --- a/Tests/CoreAPITests/WordPressOrgXMLRPCApiErrorTests.swift +++ b/Tests/CoreAPITests/WordPressOrgXMLRPCApiErrorTests.swift @@ -9,7 +9,7 @@ import XCTest class WordPressOrgXMLRPCApiErrorTests: XCTestCase { func testNSErrorBridging() throws { - for error in WordPressOrgXMLRPCApiErrorCode.allCases { + for error in WordPressOrgXMLRPCApiError.Code.allCases { let xmlRPCError = try XCTUnwrap(WordPressOrgXMLRPCApiError(code: error)) let apiError = WordPressAPIError.endpointError(xmlRPCError) let newNSError = apiError as NSError diff --git a/Tests/CoreAPITests/WordPressOrgXMLRPCApiTests.swift b/Tests/CoreAPITests/WordPressOrgXMLRPCApiTests.swift index 88283d07..e687e21e 100644 --- a/Tests/CoreAPITests/WordPressOrgXMLRPCApiTests.swift +++ b/Tests/CoreAPITests/WordPressOrgXMLRPCApiTests.swift @@ -65,7 +65,7 @@ class WordPressOrgXMLRPCApiTests: XCTestCase { failure: { (error, _) in expect.fulfill() XCTAssertEqual(error.domain, WordPressOrgXMLRPCApiErrorDomain) - XCTAssertEqual(error.code, WordPressOrgXMLRPCApiErrorCode.httpErrorStatusCode.rawValue) + XCTAssertEqual(error.code, WordPressOrgXMLRPCApiError.Code.httpErrorStatusCode.rawValue) XCTAssertEqual(error.localizedFailureReason, "An HTTP error code 404 was returned.") XCTAssertNotNil(error.userInfo[WordPressOrgXMLRPCApi.WordPressOrgXMLRPCApiErrorKeyData as String]) XCTAssertNotNil(error.userInfo[WordPressOrgXMLRPCApi.WordPressOrgXMLRPCApiErrorKeyStatusCode as String])