Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: log error messages #16935

Merged
merged 2 commits into from
Jun 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.vaadin.flow.component.ClientCallable;
Expand Down Expand Up @@ -152,10 +153,12 @@ static void invokeMethod(Component instance, Class<?> clazz,
invokeMethod(compositeContent, compositeContent.getClass(),
methodName, args, promiseId, inert);
} else {
String msg = String.format("Neither class '%s' "
+ "nor its super classes declare event handler method '%s'",
instance.getClass().getName(), methodName);
throw new IllegalStateException(msg);
getLogger().error(String.format(
"Faulty method invocation. Neither class '%s' "
+ "nor its super classes declare event handler method '%s'",
instance.getClass().getName(), methodName));
throw new IllegalStateException(
"Faulty method invocation. See server log for more details.");
}
}

Expand All @@ -166,10 +169,12 @@ private static Optional<Method> findMethod(Component instance,
.filter(method -> hasMethodAnnotation(method))
.collect(Collectors.toList());
if (methods.size() > 1) {
String msg = String.format("Class '%s' contains "
+ "several event handler method with the same name '%s'",
instance.getClass().getName(), methodName);
throw new IllegalStateException(msg);
getLogger().error(String.format(
"Method conflict in event handler. Class '%s' contains "
+ "several event handler methods with the same name '%s'",
instance.getClass().getName(), methodName));
throw new IllegalStateException(
"Method conflict in event handler with multiple methods with same name. See server log for more details.");
} else if (methods.size() == 1) {
return Optional.of(methods.get(0));
} else if (!Component.class.equals(clazz)) {
Expand Down Expand Up @@ -378,4 +383,9 @@ private static Collection<RpcDecoder> loadDecoders() {
decoders.add(new DefaultRpcDecoder());
return decoders;
}

private static Logger getLogger() {
return LoggerFactory.getLogger(
PublishedServerEventHandlerRpcHandler.class.getName());
}
}