|
37 | 37 | import com.amplifyframework.util.UserAgent; |
38 | 38 |
|
39 | 39 | import java.util.LinkedHashMap; |
40 | | -import java.util.Locale; |
41 | 40 | import java.util.Map; |
42 | 41 | import java.util.Objects; |
43 | 42 | import java.util.concurrent.ExecutorService; |
@@ -137,7 +136,7 @@ public static void configure(@NonNull final AmplifyConfiguration configuration, |
137 | 136 |
|
138 | 137 | synchronized (CONFIGURATION_LOCK) { |
139 | 138 | if (CONFIGURATION_LOCK.get()) { |
140 | | - throw new AlreadyConfiguredException(); |
| 139 | + throw new AlreadyConfiguredException("Remove the duplicate call to `Amplify.configure()`."); |
141 | 140 | } |
142 | 141 |
|
143 | 142 | // Configure User-Agent utility |
@@ -192,11 +191,7 @@ private static <P extends Plugin<?>> void updatePluginRegistry( |
192 | 191 |
|
193 | 192 | synchronized (CONFIGURATION_LOCK) { |
194 | 193 | if (CONFIGURATION_LOCK.get()) { |
195 | | - final String updateString = registryUpdateType.name().toLowerCase(Locale.US); |
196 | | - throw new AmplifyException( |
197 | | - "The client tried to " + updateString + " a plugin after calling configure().", |
198 | | - "Plugins may not be added or removed after configure(...) is called." |
199 | | - ); |
| 194 | + throw new AlreadyConfiguredException("Do not add plugins after calling `Amplify.configure()`."); |
200 | 195 | } |
201 | 196 |
|
202 | 197 | if (Empty.check(plugin.getPluginKey())) { |
@@ -246,8 +241,8 @@ public static final class AlreadyConfiguredException extends AmplifyException { |
246 | 241 | /** |
247 | 242 | * Constructs an AlreadyConfiguredException, indicating that Amplify has already been configured. |
248 | 243 | */ |
249 | | - private AlreadyConfiguredException() { |
250 | | - super("Amplify has already been configured.", "Remove the duplicate call to `Amplify.configure()`"); |
| 244 | + private AlreadyConfiguredException(@NonNull String recoverySuggestion) { |
| 245 | + super("Amplify has already been configured.", recoverySuggestion); |
251 | 246 | } |
252 | 247 | } |
253 | 248 | } |
|
0 commit comments