Skip to content

Commit ea7700b

Browse files
committed
[chore] add enums for error messages
1 parent 90be891 commit ea7700b

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

packages/repack/ios/CodeSigningErrors.swift

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ enum CodeSigningError : Int, Error {
99
case publicKeyInvalid
1010
case bundleVerificationFailed
1111
}
12+
j
13+
14+
enum CodeSigningErrorMessage: String {
15+
case tokenNotFound = "The bundle verification failed because no token for the bundle was found."
16+
case tokenInvalid = "The bundle verification failed because the token is invalid."
17+
case tokenDecodingFailed = "The bundle verification failed because the token could not be decoded."
18+
case tokenVerificationFailed = "The bundle verification failed because token verification was unsuccessful. This might mean the token has been tampered with."
19+
case publicKeyNotFound = "The bundle verification failed because PublicKey was not found in the bundle. Make sure you've added the PublicKey to the Info.plist under RepackPublicKey key."
20+
case publicKeyInvalid = "The bundle verification failed because the PublicKey is invalid."
21+
case publicKeyNotFound = "The bundle verification failed because the bundle hash is invalid."
22+
}
1223

1324
extension CodeSigningError: CustomNSError {
1425

@@ -25,19 +36,19 @@ extension CodeSigningError: CustomNSError {
2536

2637
switch self {
2738
case .tokenNotFound:
28-
failureReason = "The bundle verification failed because no token for the bundle was found."
39+
failureReason = CodeSigningErrorMessage.tokenNotFound
2940
case .tokenInvalid:
30-
failureReason = "The bundle verification failed because the token is invalid."
41+
failureReason = CodeSigningErrorMessage.
3142
case .tokenDecodingFailed:
32-
failureReason = "The bundle verification failed because the token could not be decoded."
43+
failureReason = CodeSigningErrorMessage.tokenDecodingFailed
3344
case .tokenVerificationFailed:
34-
failureReason = "The bundle verification failed because token verification was unsuccessful. This might mean the token has been tampered with."
45+
failureReason = CodeSigningErrorMessage.tokenVerificationFailed
3546
case .publicKeyNotFound:
36-
failureReason = "The bundle verification failed because PublicKey was not found in the bundle. Make sure you've added the PublicKey to the Info.plist under RepackPublicKey key."
47+
failureReason = CodeSigningErrorMessage.publicKeyNotFound
3748
case .publicKeyInvalid:
38-
failureReason = "The bundle verification failed because the PublicKey is invalid."
49+
failureReason = CodeSigningErrorMessage.publicKeyInvalid
3950
case .bundleVerificationFailed:
40-
failureReason = "The bundle verification failed because the bundle hash is invalid."
51+
failureReason = CodeSigningErrorMessage.publicKeyNotFound
4152
}
4253

4354
return [NSLocalizedFailureReasonErrorKey: failureReason]

0 commit comments

Comments
 (0)