    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 *      http://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.beanutils2;
    019
    020/**
    021 * A <strong>ConversionException</strong> indicates that a call to {@code Converter.convert()} has failed to complete successfully.
    022 *
    023 * @since 1.3
    024 */
    025public class ConversionException extends RuntimeException {
    026
    027    private static final long serialVersionUID = 1L;
    028
    029    /**
    030     * Constructs a new instance with a message formatted using {@link String#format(String, Object...)}.
    031     *
    032     * @param format See {@link String#format(String, Object...)}.
    033     * @param args   See {@link String#format(String, Object...)}.
    034     * @return a new instance with a message formatted using {@link String#format(String, Object...)}.
    035     * @since 2.0.0
    036     */
    037    public static ConversionException format(final String format, final Object... args) {
    038        return new ConversionException(String.format(format, args));
    039    }
    040
    041    /**
    042     * Constructs a new exception with the specified message.
    043     *
    044     * @param message The message describing this exception
    045     */
    046    public ConversionException(final String message) {
    047        super(message);
    048    }
    049
    050    /**
    051     * Constructs a new exception with the specified message and root cause.
    052     *
    053     * @param message The message describing this exception
    054     * @param cause   The root cause of this exception
    055     */
    056    public ConversionException(final String message, final Throwable cause) {
    057        super(message, cause);
    058    }
    059
    060    /**
    061     * Constructs a new exception with the specified root cause.
    062     *
    063     * @param cause The root cause of this exception
    064     */
    065    public ConversionException(final Throwable cause) {
    066        super(cause.getMessage());
    067    }
    068
    069}