vertx/src/main/java/eu/internetofus/common/vertx/ServiceResponseHandlers.java
/**
   * Handle with an error message.
   *
   * @param resultHandler handler that will manage the response.
   * @param status        HTTP status code.
   * @param throwable     cause that explains why has failed the request.
   */
Handle with an error message.
@param resultHandler handler that will manage the response.
@param status        HTTP status code.
@param throwable     cause that explains why has failed the request.
Handle with an error message . @param resultHandler handler that will manage the response . @param status HTTP status code . @param throwable cause that explains why has failed the request .
static void responseFailedWith(final Handler<AsyncResult<ServiceResponse>> resultHandler, final Status status,
      final Throwable throwable) {
    var code = "undefined";
    var message = "Unexpected failure";
    if (throwable instanceof ServiceException) {
      final var exception = (ServiceException) throwable;
      code = String.valueOf(exception.failureCode());
      message = exception.getMessage();
      final var errorMessage = Model.fromJsonObject(exception.getDebugInfo(), ErrorMessage.class);
      if (errorMessage != null) {
        if (errorMessage.code != null) {
          code = errorMessage.code;
        }
        if (errorMessage.message != null) {
          message = errorMessage.message;
        }
      }
    } else if (throwable instanceof ValidationErrorException) {
      final var validation = (ValidationErrorException) throwable;
      code = validation.getCode();
      message = validation.getMessage();
    } else if (throwable != null) {
      code = throwable.getClass().getSimpleName();
      message = throwable.getMessage();
    }
    responseWithErrorMessage(resultHandler, status, code, message);
  }
static void responseFailedWith ( final Handler < AsyncResult < ServiceResponse > > resultHandler , final Status status , final Throwable throwable ) { var code = "undefined" ; var message = "Unexpected failure" ; if ( throwable instanceof ServiceException ) { final var exception = ( ServiceException ) throwable ; code = String . valueOf ( exception . failureCode ( ) ) ; message = exception . getMessage ( ) ; final var errorMessage = Model . fromJsonObject ( exception . getDebugInfo ( ) , ErrorMessage . class ) ; if ( errorMessage != null ) { if ( errorMessage . code != null ) { code = errorMessage . code ; } if ( errorMessage . message != null ) { message = errorMessage . message ; } } } else if ( throwable instanceof ValidationErrorException ) { final var validation = ( ValidationErrorException ) throwable ; code = validation . getCode ( ) ; message = validation . getMessage ( ) ; } else if ( throwable != null ) { code = throwable . getClass ( ) . getSimpleName ( ) ; message = throwable . getMessage ( ) ; } responseWithErrorMessage ( resultHandler , status , code , message ) ; }
Handle with an error message.
Handle with an error message .