FIX::Illegal catch fix: RuntimeException to HttpClientErrorException

This commit is contained in:
Merel Steenbergen
2019-04-05 19:34:08 +02:00
parent 47c46b5458
commit 9ab4439f70
2 changed files with 5 additions and 4 deletions

View File

@@ -29,6 +29,7 @@ import javafx.stage.Window;
import javafx.util.Duration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.client.HttpClientErrorException;
import java.io.IOException;
import java.text.DecimalFormat;
@@ -230,8 +231,7 @@ public class RegisterWindowController {
//register the user with the provided username and password
try {
userService.registerUser(userNameText.getText(), passwordField.getText());
}
catch (RuntimeException ex) {
} catch (HttpClientErrorException ex) {
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Username Error!",
"This username has already been taken!");
return;

View File

@@ -2,6 +2,7 @@ package greenify.client.controller;
import greenify.client.Application;
import greenify.client.rest.UserService;
import greenify.common.ApplicationException;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.Parent;
@@ -14,6 +15,7 @@ import javafx.stage.Stage;
import javafx.stage.Window;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.client.HttpClientErrorException;
import java.io.IOException;
import java.util.Objects;
@@ -67,8 +69,7 @@ public class UserController {
//log the user in with the userService method
try {
userService.loginUser(usernameField.getText(), passwordField.getText());
}
catch (RuntimeException ex) {
} catch (HttpClientErrorException ex) {
AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Log-in Error!",
"Your username or password is incorrect!");
return;