github.com/phrase/openapi@v0.0.0-20240514140800-49e8a106740e/openapi-generator/templates/java/libraries/native/apiException.mustache (about) 1 {{>licenseInfo}} 2 3 package {{invokerPackage}}; 4 5 import java.net.http.HttpHeaders; 6 7 {{>generatedAnnotation}} 8 public class ApiException extends{{#useRuntimeException}} RuntimeException {{/useRuntimeException}}{{^useRuntimeException}} Exception {{/useRuntimeException}}{ 9 private int code = 0; 10 private HttpHeaders responseHeaders = null; 11 private String responseBody = null; 12 13 public ApiException() {} 14 15 public ApiException(Throwable throwable) { 16 super(throwable); 17 } 18 19 public ApiException(String message) { 20 super(message); 21 } 22 23 public ApiException(String message, Throwable throwable, int code, HttpHeaders responseHeaders, String responseBody) { 24 super(message, throwable); 25 this.code = code; 26 this.responseHeaders = responseHeaders; 27 this.responseBody = responseBody; 28 } 29 30 public ApiException(String message, int code, HttpHeaders responseHeaders, String responseBody) { 31 this(message, (Throwable) null, code, responseHeaders, responseBody); 32 } 33 34 public ApiException(String message, Throwable throwable, int code, HttpHeaders responseHeaders) { 35 this(message, throwable, code, responseHeaders, null); 36 } 37 38 public ApiException(int code, HttpHeaders responseHeaders, String responseBody) { 39 this((String) null, (Throwable) null, code, responseHeaders, responseBody); 40 } 41 42 public ApiException(int code, String message) { 43 super(message); 44 this.code = code; 45 } 46 47 public ApiException(int code, String message, HttpHeaders responseHeaders, String responseBody) { 48 this(code, message); 49 this.responseHeaders = responseHeaders; 50 this.responseBody = responseBody; 51 } 52 53 /** 54 * Get the HTTP status code. 55 * 56 * @return HTTP status code 57 */ 58 public int getCode() { 59 return code; 60 } 61 62 /** 63 * Get the HTTP response headers. 64 * 65 * @return Headers as an HttpHeaders object 66 */ 67 public HttpHeaders getResponseHeaders() { 68 return responseHeaders; 69 } 70 71 /** 72 * Get the HTTP response body. 73 * 74 * @return Response body in the form of string 75 */ 76 public String getResponseBody() { 77 return responseBody; 78 } 79 }