Skip to content

Commit 6ece5b4

Browse files
sumeruchatclaude
andauthored
SDK-470 Add CustomDebugStringConvertible to AuthFailureReason (#1073)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 3ac2f02 commit 6ece5b4

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

swift-sdk/Core/Utilities/AuthFailureReason.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,32 @@ import Foundation
2020
case authTokenGenerationError
2121
case authTokenMissing
2222
}
23+
24+
extension AuthFailureReason: CustomDebugStringConvertible {
25+
public var debugDescription: String {
26+
switch self {
27+
case .authTokenExpired:
28+
return "authTokenExpired"
29+
case .authTokenGenericError:
30+
return "authTokenGenericError"
31+
case .authTokenExpirationInvalid:
32+
return "authTokenExpirationInvalid"
33+
case .authTokenSignatureInvalid:
34+
return "authTokenSignatureInvalid"
35+
case .authTokenFormatInvalid:
36+
return "authTokenFormatInvalid"
37+
case .authTokenInvalidated:
38+
return "authTokenInvalidated"
39+
case .authTokenPayloadInvalid:
40+
return "authTokenPayloadInvalid"
41+
case .authTokenUserKeyInvalid:
42+
return "authTokenUserKeyInvalid"
43+
case .authTokenNull:
44+
return "authTokenNull"
45+
case .authTokenGenerationError:
46+
return "authTokenGenerationError"
47+
case .authTokenMissing:
48+
return "authTokenMissing"
49+
}
50+
}
51+
}

tests/unit-tests/AuthTests.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@ class AuthTests: XCTestCase {
1717
override func setUp() {
1818
super.setUp()
1919
}
20+
21+
func testAuthFailureReasonDebugDescriptions() {
22+
let expectedDescriptions: [(AuthFailureReason, String)] = [
23+
(.authTokenExpired, "authTokenExpired"),
24+
(.authTokenGenericError, "authTokenGenericError"),
25+
(.authTokenExpirationInvalid, "authTokenExpirationInvalid"),
26+
(.authTokenSignatureInvalid, "authTokenSignatureInvalid"),
27+
(.authTokenFormatInvalid, "authTokenFormatInvalid"),
28+
(.authTokenInvalidated, "authTokenInvalidated"),
29+
(.authTokenPayloadInvalid, "authTokenPayloadInvalid"),
30+
(.authTokenUserKeyInvalid, "authTokenUserKeyInvalid"),
31+
(.authTokenNull, "authTokenNull"),
32+
(.authTokenGenerationError, "authTokenGenerationError"),
33+
(.authTokenMissing, "authTokenMissing")
34+
]
35+
36+
expectedDescriptions.forEach { reason, description in
37+
XCTAssertEqual(String(describing: reason), description)
38+
}
39+
}
2040

2141
func testEmailPersistence() {
2242
let internalAPI = InternalIterableAPI.initializeForTesting()

0 commit comments

Comments
 (0)