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

     1  {{>licenseInfo}}
     2  
     3  package {{invokerPackage}};
     4  
     5  import io.vertx.core.AsyncResult;
     6  import io.vertx.core.Future;
     7  import io.vertx.core.MultiMap;
     8  
     9  {{>generatedAnnotation}}
    10  public class ApiException extends{{#useRuntimeException}} RuntimeException {{/useRuntimeException}}{{^useRuntimeException}} Exception {{/useRuntimeException}}{
    11      private int code = 0;
    12      private MultiMap responseHeaders = null;
    13      private String responseBody = null;
    14  
    15  
    16      public static <T> AsyncResult<T> fail(int failureCode, String message) {
    17          return Future.failedFuture(new ApiException(failureCode, message));
    18      }
    19  
    20      public static <T> AsyncResult<T> fail(Throwable throwable) {
    21          return Future.failedFuture(new ApiException(throwable));
    22      }
    23  
    24      public static <T> AsyncResult<T> fail(String message) {
    25          return Future.failedFuture(new ApiException(message));
    26      }
    27  
    28      public static <T> AsyncResult<T> fail(String message, Throwable throwable, int code, MultiMap responseHeaders) {
    29          return Future.failedFuture(new ApiException(message, throwable, code, responseHeaders, null));
    30      }
    31  
    32      public static <T> AsyncResult<T> fail(String message, Throwable throwable, int code, MultiMap responseHeaders, String responseBody) {
    33          return Future.failedFuture(new ApiException(message, throwable, code, responseHeaders, responseBody));
    34      }
    35  
    36      public static <T> AsyncResult<T> fail(String message, int code, MultiMap responseHeaders, String responseBody) {
    37          return Future.failedFuture(new ApiException(message, (Throwable) null, code, responseHeaders, responseBody));
    38      }
    39  
    40      public static <T> AsyncResult<T> fail(int code, MultiMap responseHeaders, String responseBody) {
    41          return Future.failedFuture(new ApiException((String) null, (Throwable) null, code, responseHeaders, responseBody));
    42      }
    43  
    44      public ApiException() {}
    45  
    46      public ApiException(Throwable throwable) {
    47          super(throwable);
    48      }
    49  
    50      public ApiException(String message) {
    51          super(message);
    52      }
    53  
    54      public ApiException(String message, Throwable throwable, int code, MultiMap responseHeaders, String responseBody) {
    55          super(message, throwable);
    56          this.code = code;
    57          this.responseHeaders = responseHeaders;
    58          this.responseBody = responseBody;
    59      }
    60  
    61      public ApiException(String message, int code, MultiMap responseHeaders, String responseBody) {
    62          this(message, (Throwable) null, code, responseHeaders, responseBody);
    63      }
    64  
    65      public ApiException(String message, Throwable throwable, int code, MultiMap responseHeaders) {
    66          this(message, throwable, code, responseHeaders, null);
    67      }
    68  
    69      public ApiException(int code, MultiMap responseHeaders, String responseBody) {
    70          this((String) null, (Throwable) null, code, responseHeaders, responseBody);
    71      }
    72  
    73      public ApiException(int code, String message) {
    74          super(message);
    75          this.code = code;
    76      }
    77  
    78      public ApiException(int code, String message, MultiMap responseHeaders, String responseBody) {
    79          this(code, message);
    80          this.responseHeaders = responseHeaders;
    81          this.responseBody = responseBody;
    82      }
    83  
    84      /**
    85       * Get the HTTP status code.
    86       *
    87       * @return HTTP status code
    88       */
    89      public int getCode() {
    90          return code;
    91      }
    92  
    93      /**
    94       * Get the HTTP response headers.
    95       *
    96       * @return A map of list of string
    97       */
    98      public MultiMap getResponseHeaders() {
    99          return responseHeaders;
   100      }
   101  
   102      /**
   103       * Get the HTTP response body.
   104       *
   105       * @return Response body in the form of string
   106       */
   107      public String getResponseBody() {
   108          return responseBody;
   109      }
   110  }