FIX::Illegal catch fix: RuntimeException to HttpClientErrorException

This commit is contained in:
Merel Steenbergen
2019-04-05 19:34:08 +02:00
parent dc432df120
commit fb22937864
2 changed files with 5 additions and 2 deletions

View File

@@ -30,6 +30,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;
@@ -221,7 +222,7 @@ public class RegisterWindowController {
//register the user with the provided username and password
try {
userService.registerUser(userNameText.getText(), passwordField.getText());
} catch (Exception 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,7 +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;