|
30 | 30 | import com.javadiscord.jdi.internal.api.application_commands.DeleteCommandRequest;
|
31 | 31 | import com.javadiscord.jdi.internal.cache.Cache;
|
32 | 32 | import com.javadiscord.jdi.internal.cache.CacheType;
|
| 33 | +import com.javadiscord.jdi.internal.exceptions.GatewayException; |
| 34 | +import com.javadiscord.jdi.internal.exceptions.InvalidBotTokenException; |
33 | 35 | import com.javadiscord.jdi.internal.gateway.*;
|
34 | 36 | import com.javadiscord.jdi.internal.gateway.identify.IdentifyRequest;
|
35 | 37 |
|
@@ -242,7 +244,7 @@ private void loadComponents() {
|
242 | 244 | if (componentLoader != null) {
|
243 | 245 | componentLoader.loadComponents();
|
244 | 246 | } else {
|
245 |
| - throw new RuntimeException("Unable to create ComponentLoader instance"); |
| 247 | + throw new InstantiationException("Unable to create ComponentLoader instance"); |
246 | 248 | }
|
247 | 249 | } catch (Exception e) {
|
248 | 250 | LOGGER.warn("Component loading failed", e);
|
@@ -357,15 +359,15 @@ private static Gateway getGatewayURL(String authentication) {
|
357 | 359 | httpClient.send(request, HttpResponse.BodyHandlers.ofString());
|
358 | 360 |
|
359 | 361 | if (response.statusCode() == 401) {
|
360 |
| - throw new RuntimeException("Invalid bot token provided"); |
| 362 | + throw new InvalidBotTokenException("Invalid bot token provided"); |
361 | 363 | }
|
362 | 364 | if (response.statusCode() != 200) {
|
363 |
| - throw new RuntimeException("Unexpected error occurred: " + response.body()); |
| 365 | + throw new GatewayException("Unexpected error occurred: " + response.body()); |
364 | 366 | }
|
365 | 367 | return OBJECT_MAPPER.readValue(response.body(), Gateway.class);
|
366 | 368 | } catch (Exception e) {
|
367 | 369 | LOGGER.error("Failed to fetch the gateway URL from discord", e);
|
368 |
| - throw new RuntimeException(e); |
| 370 | + throw new GatewayException(e.getMessage()); |
369 | 371 | }
|
370 | 372 | }
|
371 | 373 |
|
|
0 commit comments