ParameterOutOfRangeException.java

  1. /*  This file is part of Openrouteservice.
  2.  *
  3.  *  Openrouteservice is free software; you can redistribute it and/or modify it under the terms of the
  4.  *  GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1
  5.  *  of the License, or (at your option) any later version.

  6.  *  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  7.  *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8.  *  See the GNU Lesser General Public License for more details.

  9.  *  You should have received a copy of the GNU Lesser General Public License along with this library;
  10.  *  if not, see <https://www.gnu.org/licenses/>.
  11.  */
  12. package org.heigit.ors.exceptions;

  13. import org.heigit.ors.common.StatusCode;

  14. public class ParameterOutOfRangeException extends StatusCodeException {
  15.     private static final long serialVersionUID = 7728944138955234463L;

  16.     private static final String PARAMETER_KEY = "Parameter";

  17.     public ParameterOutOfRangeException(int errorCode, String paramName) {
  18.         super(StatusCode.BAD_REQUEST, errorCode, PARAMETER_KEY + " '" + paramName + "' is out of range.");
  19.     }

  20.     public ParameterOutOfRangeException(int errorCode, String paramName, String customMessage) {
  21.         super(StatusCode.BAD_REQUEST, errorCode, PARAMETER_KEY + " '" + paramName + "' is out of range: " + customMessage);
  22.     }

  23.     public ParameterOutOfRangeException(int errorCode, String paramName, String value, String maxRangeValue) {
  24.         super(StatusCode.BAD_REQUEST, errorCode, PARAMETER_KEY + " '" + paramName + "=" + value + "' is out of range. Maximum possible value is " + maxRangeValue + ".");
  25.     }

  26.     public ParameterOutOfRangeException(String paramName, String value, String maxRangeValue) {
  27.         this(-1, paramName, value, maxRangeValue);
  28.     }
  29. }