Java 异常处理vaadin
我有一个登录按钮,它调用一个登录函数Java 异常处理vaadin,java,vaadin7,Java,Vaadin7,我有一个登录按钮,它调用一个登录函数 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 Excep
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;
}
现在转到登录功能:
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执行捕获此错误的操作vaadin中的SetErrorHandler执行捕获此错误的操作尝试从signIn()方法中删除Try-catch块。如果signIn()中出现异常,则它将传播到原始方法。不,我已经尝试过,但仍然无法在window中捕获异常。您可以发布窗口的代码吗?请查看windows代码在代码中的什么位置出现异常?尝试从signIn()方法中删除Try catch块。如果signIn()中出现异常,则它将传播到原始方法。不,我已经尝试过,但仍然无法在window中捕获异常。您可以发布窗口的代码吗?请查看windows代码在代码中的什么位置出现异常?