我有一个调用登录函数的登录按钮
if (button == loginbutton) {
try {
login();
} catch (Exception e) {
// I am adding a window compnent here that will display the exception with the message
}
}
现在我的登录功能:
private void login() throws Exception {
accessInterface.signIn(m_username.getValue(), m_password.getValue());
m_loginListener.loginSuccessful();
}
现在进入登录功能:
public boolean signIn(String p_username, String p_password) throws Exception {
try {
m_user = UserAuthentication.authenticate(p_username, p_password,
ServiceSettings.getInstance().getAuthenticationServiceLocation());
} catch (Exception e) {
m_logger.error("CATCH",e);
throw e;
}
// Setting the current user
CurrentUser.set(m_user);
return true;
}
现在它会验证服务的方法:
public static uInterface authenticate(String p_username, String p_password, String p_Location) throws Exception {
// here it is authenticating user
}
现在,问题是它没有显示该窗口组件中的错误或异常。我应该怎么办?我想在窗口组件 vaadin 中捕获异常
Windows 代码
它需要 ui 对象、窗口标题、消息,然后单击详细信息按钮时获取异常详细信息
ExceptionDetails.showMessage(getUI(),
"Error in signing in",
"ExceptionInformation",
e.getLocalizedMessage(),
new ActionListenerDetail() {
private static final long serialVersionUID = 1L;
@Override
public void onClickDetails() {
m_username.focus();
m_loginButton.setEnabled(true);
}
}
);
最佳答案
vaadin 中的 SetErrorHandler 可以捕获此错误
关于java - 异常处理vaadin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36590001/