private CommandProcessingException handle()

in src/main/java/org/apache/fineract/cn/command/internal/CommandBus.java [241:267]


  private CommandProcessingException handle(final Throwable th, final CommandSource commandSource,
                                            final Class<?>[] declaredExceptions) {
    final Throwable cause;
    if (th.getClass().isAssignableFrom(InvocationTargetException.class)) {
      cause = th.getCause();
    } else {
      cause = th;
    }

    final String failureMessage = cause.getClass().getSimpleName() + ": "
        + (cause.getMessage() != null ? cause.getMessage() : "no details available");

    this.logger.warn("Error while processing command. {}", failureMessage);

    this.updateCommandSource(commandSource, failureMessage);

    if (declaredExceptions != null) {
      if (Arrays.asList(declaredExceptions).contains(cause.getClass())) {
        if (cause instanceof RuntimeException) {
          throw RuntimeException.class.cast(cause);
        } else {
          this.logger.info("Exception {} is not a runtime exception.", cause.getClass().getSimpleName());
        }
      }
    }
    return new CommandProcessingException(cause.getMessage(), cause);
  }