Skip to content

Commit

Permalink
Merge pull request #4896 from Jmr3366/j_develop_rest_ret
Browse files Browse the repository at this point in the history
J develop rest ret
  • Loading branch information
cwisniew authored Sep 8, 2024
2 parents 6c315d5 + 8a95d62 commit 0768d47
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
*/
package net.rptools.maptool.client.functions;

import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.*;
import com.google.gson.reflect.TypeToken;
import java.awt.Desktop;
import java.io.IOException;
Expand Down Expand Up @@ -218,10 +217,11 @@ private Object executeClientCall(String functionName, Request request, boolean f
throws ParserException {

// Execute the call and check the response...
JsonObject errjson = new JsonObject();
try (Response response = client.newCall(request).execute()) {
if (!response.isSuccessful() && !fullResponse) {
throw new ParserException(
I18N.getText("macro.function.rest.error.response", functionName, response.code()));
errjson.addProperty("error", response.code());
return errjson;
}

if (fullResponse) {
Expand All @@ -231,7 +231,8 @@ private Object executeClientCall(String functionName, Request request, boolean f
}

} catch (IllegalArgumentException | IOException e) {
throw new ParserException(I18N.getText("macro.function.rest.error.unknown", functionName, e));
errjson.addProperty("error", e.toString());
return errjson;
}
}

Expand Down

0 comments on commit 0768d47

Please sign in to comment.