1
我已經登錄按鈕調用一個登錄功能異常處理vaadin
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);
}
}
);
嘗試從signIn()方法中刪除try-catch塊。如果在signIn()中發生異常,那麼它將傳播到原始方法。 –
不,我已經嘗試過,但仍然沒有捕捉到窗口中的異常 –
你能發佈窗口的代碼嗎? –