All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.json.schema.common.ValidationExceptionImpl Maven / Gradle / Ivy

The newest version!
package io.vertx.json.schema.common;

import io.vertx.core.json.pointer.JsonPointer;
import io.vertx.json.schema.ValidationException;

import java.util.Collection;
import java.util.Objects;
import java.util.stream.Collectors;

public class ValidationExceptionImpl extends ValidationException {

  public ValidationExceptionImpl(String message, String keyword, Object input) {
    super(message, keyword, input);
  }

  public ValidationExceptionImpl(String message, Throwable cause, String keyword, Object input) {
    super(message, cause, keyword, input);
  }

  public ValidationExceptionImpl(String message, Collection causes, String keyword, Object input) {
    super(message + ". Multiple causes: " + formatExceptions(causes), keyword, input);
  }

  public void setInputScope(JsonPointer scope) {
    this.inputScope = scope;
  }

  private static String formatExceptions(Collection throwables) {
    if (throwables == null) {
      return "[]";
    }
    return "[" + throwables
      .stream()
      .filter(Objects::nonNull)
      .map(Throwable::getMessage)
      .collect(Collectors.joining(", ")) + "]";
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy