response.body instead of statuscode and return full recipe
This commit is contained in:
parent
277de13028
commit
8be89e1863
1 changed files with 5 additions and 5 deletions
|
|
@ -41,7 +41,7 @@ public class ServerUtils {
|
|||
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
|
||||
if(response.statusCode() != statusOK){
|
||||
throw new IOException("No recipe to get. Server responds with " + response.statusCode());
|
||||
throw new IOException("No recipe to get. Server responds with " + response.body());
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ public class ServerUtils {
|
|||
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
|
||||
if(response.statusCode() != statusOK){
|
||||
throw new IOException("failed finding recipe with id: "+ id + " body: " + response.statusCode());
|
||||
throw new IOException("failed finding recipe with id: "+ id + " body: " + response.body());
|
||||
}
|
||||
|
||||
return objectMapper.readValue(response.body(),Recipe.class);
|
||||
|
|
@ -96,7 +96,7 @@ public class ServerUtils {
|
|||
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
|
||||
if(response.statusCode() != statusOK){
|
||||
throw new IOException("Failed to add Recipe: " + newRecipe.getId() + "body: " + response.statusCode());
|
||||
throw new IOException("Failed to add Recipe: " + newRecipe.toDetailedString() + "body: " + response.body());
|
||||
}
|
||||
|
||||
return objectMapper.readValue(response.body(),Recipe.class);
|
||||
|
|
@ -114,7 +114,7 @@ public class ServerUtils {
|
|||
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
|
||||
if(response.statusCode() != statusOK){
|
||||
throw new IOException("Failed removing recipe with id: " + id + "body: " + response.statusCode());
|
||||
throw new IOException("Failed removing recipe with id: " + id + "body: " + response.body());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ public class ServerUtils {
|
|||
|
||||
//200 is the status code for success, other codes can mean there is no recipe to clone
|
||||
if(response.statusCode() != statusOK){
|
||||
throw new IOException("Failed to get recipe to clone with id: " + id + "body: " + response.statusCode());
|
||||
throw new IOException("Failed to get recipe to clone with id: " + id + "body: " + response.body());
|
||||
}
|
||||
// recipe exists so you can make a "new" recipe aka the clone
|
||||
Recipe recipe = objectMapper.readValue(response.body(), Recipe.class);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue