Skip to content

Commit 3d340bd

Browse files
committed
Sonar
1 parent 7e1161c commit 3d340bd

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

annotations/src/main/java/com/javadiscord/jdi/core/processor/loader/ComponentLoader.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private void processClassFile(File classFile) {
4141
}
4242
}
4343

44-
private void processClassMethods(Class<?> clazz) throws Exception {
44+
private void processClassMethods(Class<?> clazz) {
4545
for (Method method : clazz.getMethods()) {
4646
if (method.isAnnotationPresent(Component.class)) {
4747
registerComponent(method);
@@ -51,10 +51,15 @@ private void processClassMethods(Class<?> clazz) throws Exception {
5151

5252
private void registerComponent(
5353
Method method
54-
) throws InvocationTargetException, IllegalAccessException {
54+
) {
5555
Class<?> returnType = method.getReturnType();
5656
if (!COMPONENTS.containsKey(returnType)) {
57-
COMPONENTS.put(returnType, method.invoke(null));
57+
try {
58+
COMPONENTS.put(returnType, method.invoke(null));
59+
} catch (IllegalAccessException | InvocationTargetException e) {
60+
LOGGER.error("Failed to register component {}", method.getName(), e);
61+
return;
62+
}
5863
LOGGER.info("Loaded component {}", returnType.getName());
5964
} else {
6065
LOGGER.error("Component {} already loaded", returnType.getName());

core/src/main/java/com/javadiscord/jdi/core/GatewayEventListenerAnnotations.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,11 @@ private void invokeAnnotatedMethods(Class<? extends Annotation> annotationClass,
255255
private void invokeMethod(Object listener, Method method, Object event) {
256256
List<Object> paramOrder = getParamOrder(method, event);
257257
if (paramOrder.size() != method.getParameterCount()) {
258-
throw new RuntimeException(
259-
"Bound " + paramOrder.size() + " parameters but expected "
260-
+ method.getParameterCount()
258+
LOGGER.error(
259+
"Bound {} parameters but expected {}", paramOrder.size(), method.getParameterCount()
261260
);
261+
return;
262262
}
263-
264263
try {
265264
LOGGER.trace("Invoking method {} with params {}", method.getName(), paramOrder);
266265
method.invoke(listener, paramOrder.toArray());

0 commit comments

Comments
 (0)