Fixed pipeline issues and added comment
This commit is contained in:
parent
b985aa283f
commit
e5f7df7318
2 changed files with 6 additions and 5 deletions
|
|
@ -68,8 +68,9 @@ public class IngredientsPopupCtrl {
|
||||||
refresh(); // reload list from server
|
refresh(); // reload list from server
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if (e.getMessage() != null && e.getMessage().startsWith("DUPLICATE:")) {
|
if (e.getMessage() != null && e.getMessage().startsWith("DUPLICATE:")) {
|
||||||
showError("An ingredient with the name" + name + " already exists." +
|
showError("An ingredient with the name " + name + " already exists." +
|
||||||
" Please provide a different name.");
|
" Please provide a different name."); //checks if error received has the DUPLICATE string and creates a showError instance with an appropriate error message and description
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
showError("Failed to create ingredient: " + e.getMessage());
|
showError("Failed to create ingredient: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -278,9 +278,9 @@ public class ServerUtils {
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
|
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||||
|
final int DUPLICATE_STATUS_CODE = 409;
|
||||||
if (response.statusCode() == 409) {
|
if (response.statusCode() == DUPLICATE_STATUS_CODE) {
|
||||||
throw new IOException("An ingredient with the name '" + name + "' already exists.");
|
throw new IOException("DUPLICATE: An ingredient with the name '" + name + "' already exists.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.statusCode() != statusOK) {
|
if (response.statusCode() != statusOK) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue