So I'm not really having a problem but I do have a question about how-to debug the proper way. For example, in my case I have method inside Global class.
When I run this from another class I'd have to surround it with a try/catch. However, when something fails inside my code it just shows me the "throw". All the other Log.*/System.out.println() won't show.
public <T> T run(Class<T> a, String url, File file, String jsonObject, String contentType) throws Exception {
if(file.exists()){
requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("jsonObject", jsonObject)
.addFormDataPart("image", file.getName(), RequestBody.create(MediaType.parse(contentType), file))
.build();
} else{
requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("jsonObject", jsonObject)
.build();
}
Request request = new Request.Builder()
.url(API_SERVER + url)
.post(requestBody)
.build();
System.out.println
Response response = client.newCall(request).execute();
if (response.isSuccessful()) throw new IllegalArgumentException("!response.isSuccessful():" + response.body().string());
String jsonResponse = response.body().string();
response.body().close();
Gson gson = new Gson();
return gson.fromJson(jsonResponse, a);
}
The only way to see anything in my case is to change the if-statement.
if (!response.isSuccessful()) throw new IllegalArgumentException("!response.isSuccessful():" + response.body().string());
What could you guys recommend me to change so I can debug a little easier instead of replacing my if, waiting for rebuilding, deploying and testing...