github.com/phrase/openapi@v0.0.0-20240514140800-49e8a106740e/openapi-generator/templates/java/apiException.mustache (about)

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