    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *      https://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017
    018package org.apache.commons.validator;
    019
    020import java.security.PrivilegedActionException;
    021import java.util.IllegalFormatException;
    022/**
    023 * The base exception for the Validator Framework. All other {@code Exception}s thrown during calls to {@code Validator.validate()} are considered errors.
    024 */
    025public class ValidatorException extends Exception {
    026
    027    private static final long serialVersionUID = 1025759372615616964L;
    028
    029    /**
    030     * Constructs an Exception with no specified detail message.
    031     */
    032    public ValidatorException() {
    033    }
    034
    035    /**
    036     * Constructs an Exception with the specified detail message.
    037     *
    038     * @param message The error message.
    039     */
    040    public ValidatorException(final String message) {
    041        super(message);
    042    }
    043
    044    /**
    045     * Constructs an Exception with a message and the underlying cause.
    046     *
    047     * @param format See {@link String#format(String, Object...)}.
    048     * @param args   See {@link String#format(String, Object...)}.
    049     * @throws IllegalFormatException See {@link String#format(String, Object...)}.
    050     * @since 1.11.0
    051     */
    052    public ValidatorException(final String format, final Object... args) {
    053        super(String.format(format, args));
    054    }
    055
    056    /**
    057     * Constructs a new exception with the specified detail message and cause.
    058     * <p>
    059     * Note that the detail message associated with {@code cause} is <em>not</em> automatically incorporated in this exception's detail message.
    060     * </p>
    061     *
    062     * @param message The detail message (which is saved for later retrieval by the {@link #getMessage()} method).
    063     * @param cause   The cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that
    064     *                the cause is nonexistent or unknown.)
    065     * @since 1.11.0
    066     */
    067    public ValidatorException(final String message, final Throwable cause) {
    068        super(message, cause);
    069    }
    070
    071    /**
    072     * Constructs a new exception with the specified cause and a detail message of {@code (cause==null ? null : cause.toString())} (which typically contains the
    073     * class and detail message of {@code cause}). This constructor is useful for exceptions that are little more than wrappers for other throwables (for
    074     * example, {@link PrivilegedActionException}).
    075     *
    076     * @param cause The cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that the
    077     *              cause is nonexistent or unknown.)
    078     * @since 1.11.0
    079     */
    080    public ValidatorException(final Throwable cause) {
    081        super(cause);
    082    }
    083}