Skip to content

Commit eb302f9

Browse files
authored
Add new error reason: BadEnvironmentKeyInToken (#229)
* Add badEnvironmentKeyInToken error case * Add raw string value to errorDescription of .unknown case.
1 parent e73454a commit eb302f9

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Sources/APNSCore/APNSError.swift

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public struct APNSError: Error {
5454
case internalServerError
5555
case serviceUnavailable
5656
case shutdown
57+
case badEnvironmentKeyInToken
5758
case unknown(String)
5859

5960
public init(rawValue: RawValue) {
@@ -116,6 +117,8 @@ public struct APNSError: Error {
116117
self = .serviceUnavailable
117118
case "Shutdown":
118119
self = .shutdown
120+
case "BadEnvironmentKeyInToken":
121+
self = .badEnvironmentKeyInToken
119122
default:
120123
self = .unknown(rawValue)
121124
}
@@ -181,6 +184,8 @@ public struct APNSError: Error {
181184
return "ServiceUnavailable"
182185
case .shutdown:
183186
return "Shutdown"
187+
case .badEnvironmentKeyInToken:
188+
return "BadEnvironmentKeyInToken"
184189
case .unknown(let string):
185190
return string
186191
}
@@ -246,8 +251,10 @@ public struct APNSError: Error {
246251
return "The service is unavailable"
247252
case .shutdown:
248253
return "The server is shutting down"
249-
case .unknown:
250-
return "Indicates an error reason that is unknown to `APNSwift`. If you receive this please file an issue so that we can extend the known error reasons"
254+
case .badEnvironmentKeyInToken:
255+
return "Environment mismatch between key and APNs endpoint"
256+
case .unknown(let string):
257+
return "Indicates an error reason that is unknown value \"\(string)\" to `APNSwift`. If you receive this please file an issue so that we can extend the known error reasons"
251258
}
252259
}
253260
}
@@ -379,7 +386,11 @@ public struct APNSError: Error {
379386
public static var shutdown: Self {
380387
return .init(_reason: .shutdown)
381388
}
382-
389+
390+
public static var badEnvironmentKeyInToken: Self {
391+
return .init(_reason: .badEnvironmentKeyInToken)
392+
}
393+
383394
init(_reason: APNSError.ErrorReason.Reason) {
384395
self._reason = _reason
385396
}

0 commit comments

Comments
 (0)