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

eu.ciechanowiec.conditional.WrapperException Maven / Gradle / Ivy

Go to download

Java utility-library designed to replace `if-else` statements and ternary operators with a featured fluent interface

There is a newer version: 1.0.5
Show newest version
package eu.ciechanowiec.conditional;

/**
 * Unchecked exception that is used to wrap a checked {@link Exception}.
 */
public class WrapperException extends RuntimeException {

    /**
     * Specific details about this exception.
     */
    private final String message;

    /**
     * Constructs an instance of a {@link WrapperException}.
     * @param wrappedException exception that will be wrapped by a created
     * instance of a {@link WrapperException} as its cause
     */
    WrapperException(Exception wrappedException) {
        Class wrappedExceptionClass = wrappedException.getClass();
        String wrappedExceptionName = wrappedExceptionClass.getName();
        String wrappedExceptionMessage = wrappedException.getMessage();
        message = String.format("Wrapped exception: '%s'. Wrapped exception message: '%s'. " +
                                "See the cause exception for details",
                                wrappedExceptionName, wrappedExceptionMessage);
        this.initCause(wrappedException);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String getMessage() {
        return message;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy