1 import AuthenticationServices
2 import ABI48_0_0ExpoModulesCore
3 
4 final class InvalidScopeException: GenericException<Int> {
5   override var reason: String {
6     "Invalid Apple authentication scope: \(param)"
7   }
8 }
9 
10 final class InvalidOperationException: GenericException<Int> {
11   override var reason: String {
12     "Invalid type of Apple authentication operation: \(param)"
13   }
14 }
15 
16 final class RequestCanceledException: Exception {
17   override var reason: String {
18     "The user canceled the authorization attempt"
19   }
20 }
21 
22 final class InvalidResponseException: Exception {
23   override var reason: String {
24     "The authorization request received an invalid response"
25   }
26 }
27 
28 final class RequestNotHandledException: Exception {
29   override var reason: String {
30     "The authorization request wasn’t handled"
31   }
32 }
33 
34 final class RequestFailedException: Exception {
35   override var reason: String {
36     "The authorization attempt failed"
37   }
38 }
39 
40 final class RequestNotInteractiveException: Exception {
41   override var reason: String {
42     "The authorization request isn’t interactive"
43   }
44 }
45 
46 final class RequestUnknownException: Exception {
47   override var reason: String {
48     "The authorization attempt failed for an unknown reason"
49   }
50 }
51 
exceptionForAuthorizationErrornull52 func exceptionForAuthorizationError(_ error: ASAuthorizationError) -> Exception {
53   switch error.code {
54   case .unknown:
55     return RequestUnknownException()
56   case .canceled:
57     return RequestCanceledException()
58   case .invalidResponse:
59     return InvalidResponseException()
60   case .notHandled:
61     return RequestNotHandledException()
62   case .failed:
63     return RequestFailedException()
64   case .notInteractive:
65     return RequestNotInteractiveException()
66   }
67 }
68