|
| 1 | +/* |
| 2 | + * Copyright 2026 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"). |
| 5 | + * You may not use this file except in compliance with the License. |
| 6 | + * A copy of the License is located at |
| 7 | + * |
| 8 | + * http://aws.amazon.com/apache2.0 |
| 9 | + * |
| 10 | + * or in the "license" file accompanying this file. This file is distributed |
| 11 | + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 12 | + * express or implied. See the License for the specific language governing |
| 13 | + * permissions and limitations under the License. |
| 14 | + */ |
| 15 | +package com.amplifyframework.api.aws |
| 16 | + |
| 17 | +import com.amplifyframework.annotations.ExperimentalAmplifyApi |
| 18 | +import com.amplifyframework.api.ApiException |
| 19 | +import com.amplifyframework.api.ApiException.ApiAuthException |
| 20 | + |
| 21 | +/** |
| 22 | + * Sealed auth exception hierarchy for the AppSync client. |
| 23 | + * Extends [ApiAuthException] so existing `catch (ApiAuthException)` and |
| 24 | + * `throws ApiAuthException` declarations work without changes. |
| 25 | + */ |
| 26 | +@ExperimentalAmplifyApi |
| 27 | +sealed class AppSyncAuthException( |
| 28 | + message: String, |
| 29 | + cause: Throwable?, |
| 30 | + recoverySuggestion: String |
| 31 | +) : ApiAuthException(message, cause, recoverySuggestion) |
| 32 | + |
| 33 | +@ExperimentalAmplifyApi |
| 34 | +class AppSyncTokenFetchException( |
| 35 | + message: String, |
| 36 | + cause: Throwable?, |
| 37 | + recoverySuggestion: String |
| 38 | +) : AppSyncAuthException(message, cause, recoverySuggestion) |
| 39 | + |
| 40 | +@ExperimentalAmplifyApi |
| 41 | +class AppSyncProviderNotConfiguredException( |
| 42 | + message: String, |
| 43 | + cause: Throwable?, |
| 44 | + recoverySuggestion: String |
| 45 | +) : AppSyncAuthException(message, cause, recoverySuggestion) |
| 46 | + |
| 47 | +@ExperimentalAmplifyApi |
| 48 | +class AppSyncSigningException( |
| 49 | + message: String, |
| 50 | + cause: Throwable?, |
| 51 | + recoverySuggestion: String |
| 52 | +) : AppSyncAuthException(message, cause, recoverySuggestion) |
| 53 | + |
| 54 | +@ExperimentalAmplifyApi |
| 55 | +class AppSyncTokenParsingException( |
| 56 | + message: String, |
| 57 | + cause: Throwable?, |
| 58 | + recoverySuggestion: String |
| 59 | +) : AppSyncAuthException(message, cause, recoverySuggestion) |
| 60 | + |
| 61 | +@ExperimentalAmplifyApi |
| 62 | +class AppSyncAuthorizationClaimException( |
| 63 | + message: String, |
| 64 | + cause: Throwable?, |
| 65 | + recoverySuggestion: String |
| 66 | +) : AppSyncAuthException(message, cause, recoverySuggestion) |
| 67 | + |
| 68 | +@ExperimentalAmplifyApi |
| 69 | +class AppSyncAuthExhaustedException( |
| 70 | + message: String, |
| 71 | + cause: Throwable?, |
| 72 | + recoverySuggestion: String |
| 73 | +) : AppSyncAuthException(message, cause, recoverySuggestion) |
| 74 | + |
| 75 | +@ExperimentalAmplifyApi |
| 76 | +class AppSyncAuthUnknownException( |
| 77 | + message: String, |
| 78 | + cause: Throwable?, |
| 79 | + recoverySuggestion: String |
| 80 | +) : AppSyncAuthException(message, cause, recoverySuggestion) |
| 81 | + |
| 82 | +/** |
| 83 | + * Sealed non-auth exception hierarchy for the AppSync client. |
| 84 | + * Extends [ApiException] for backward compatibility. |
| 85 | + */ |
| 86 | +@ExperimentalAmplifyApi |
| 87 | +sealed class AppSyncException( |
| 88 | + message: String, |
| 89 | + cause: Throwable?, |
| 90 | + recoverySuggestion: String |
| 91 | +) : ApiException(message, cause, recoverySuggestion) |
| 92 | + |
| 93 | +@ExperimentalAmplifyApi |
| 94 | +class AppSyncInvalidConfigException( |
| 95 | + message: String, |
| 96 | + cause: Throwable?, |
| 97 | + recoverySuggestion: String |
| 98 | +) : AppSyncException(message, cause, recoverySuggestion) |
| 99 | + |
| 100 | +@ExperimentalAmplifyApi |
| 101 | +class AppSyncEndpointResolutionException( |
| 102 | + message: String, |
| 103 | + cause: Throwable?, |
| 104 | + recoverySuggestion: String |
| 105 | +) : AppSyncException(message, cause, recoverySuggestion) |
| 106 | + |
| 107 | +@ExperimentalAmplifyApi |
| 108 | +class AppSyncDeserializationException( |
| 109 | + message: String, |
| 110 | + cause: Throwable?, |
| 111 | + recoverySuggestion: String |
| 112 | +) : AppSyncException(message, cause, recoverySuggestion) |
| 113 | + |
| 114 | +@ExperimentalAmplifyApi |
| 115 | +class AppSyncSubscriptionConnectionException( |
| 116 | + message: String, |
| 117 | + cause: Throwable?, |
| 118 | + recoverySuggestion: String |
| 119 | +) : AppSyncException(message, cause, recoverySuggestion) |
| 120 | + |
| 121 | +@ExperimentalAmplifyApi |
| 122 | +class AppSyncSubscriptionTimeoutException( |
| 123 | + message: String, |
| 124 | + cause: Throwable?, |
| 125 | + recoverySuggestion: String |
| 126 | +) : AppSyncException(message, cause, recoverySuggestion) |
| 127 | + |
| 128 | +@ExperimentalAmplifyApi |
| 129 | +class AppSyncRequestValidationException( |
| 130 | + message: String, |
| 131 | + cause: Throwable?, |
| 132 | + recoverySuggestion: String |
| 133 | +) : AppSyncException(message, cause, recoverySuggestion) |
| 134 | + |
| 135 | +@ExperimentalAmplifyApi |
| 136 | +class AppSyncInvalidStateException( |
| 137 | + message: String, |
| 138 | + cause: Throwable?, |
| 139 | + recoverySuggestion: String |
| 140 | +) : AppSyncException(message, cause, recoverySuggestion) |
| 141 | + |
| 142 | +@ExperimentalAmplifyApi |
| 143 | +class AppSyncNetworkException( |
| 144 | + message: String, |
| 145 | + cause: Throwable?, |
| 146 | + recoverySuggestion: String |
| 147 | +) : AppSyncException(message, cause, recoverySuggestion) |
| 148 | + |
| 149 | +@ExperimentalAmplifyApi |
| 150 | +class AppSyncUnknownException( |
| 151 | + message: String, |
| 152 | + cause: Throwable?, |
| 153 | + recoverySuggestion: String |
| 154 | +) : AppSyncException(message, cause, recoverySuggestion) |
0 commit comments