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

org.opentripplanner.routing.error.RoutingValidationException Maven / Gradle / Ivy

There is a newer version: 2.6.0
Show newest version
package org.opentripplanner.routing.error;

import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletionException;
import java.util.stream.Collectors;
import org.opentripplanner.routing.api.response.RoutingError;

public class RoutingValidationException extends RuntimeException {

  private final List routingErrors;

  /**
   * An error with the input data which results in itineraries not being returned for a type of
   * search.
   */
  public RoutingValidationException(List routingErrors) {
    this.routingErrors = routingErrors;
  }

  public static void unwrapAndRethrowCompletionException(CompletionException e) {
    if (e.getCause() instanceof RoutingValidationException) {
      throw (RoutingValidationException) e.getCause();
    } else if (e.getCause() instanceof RuntimeException) {
      throw (RuntimeException) e.getCause();
    }
    throw e;
  }

  public List getRoutingErrors() {
    return routingErrors;
  }

  @Override
  public String getMessage() {
    return routingErrors.stream().map(Objects::toString).collect(Collectors.joining("\n"));
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy