Skip to content

Commit 287bb7d

Browse files
committed
fixed builder, error msg
1 parent ddb1d6e commit 287bb7d

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

modules/swagger-codegen/src/main/resources/Java/apiInvoker.mustache

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public class ApiInvoker {
226226
}
227227
else if ("DELETE".equals(method)) {
228228
if(body == null)
229-
response = builder.delete(ClientResponse.class, serialize(body));
229+
response = builder.delete(ClientResponse.class);
230230
else
231231
response = builder.type(contentType).delete(ClientResponse.class, serialize(body));
232232
}
@@ -237,12 +237,26 @@ public class ApiInvoker {
237237
return null;
238238
}
239239
else if(response.getClientResponseStatus().getFamily() == Family.SUCCESSFUL) {
240-
return (String) response.getEntity(String.class);
240+
if(response.hasEntity()) {
241+
return (String) response.getEntity(String.class);
242+
}
243+
else {
244+
return "";
245+
}
241246
}
242247
else {
248+
String message = "error";
249+
if(response.hasEntity()) {
250+
try{
251+
message = String.valueOf(response.getEntity(String.class));
252+
}
253+
catch (RuntimeException e) {
254+
// e.printStackTrace();
255+
}
256+
}
243257
throw new ApiException(
244258
response.getClientResponseStatus().getStatusCode(),
245-
response.getEntity(String.class));
259+
message);
246260
}
247261
}
248262

0 commit comments

Comments
 (0)