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

org.babyfish.jimmer.DraftConsumerUncheckedException Maven / Gradle / Ivy

package org.babyfish.jimmer;

/**
 * If {@link DraftConsumer} throws an exception
 * that is neither RuntimeException nor Error,
 * wrap that exception and then rethrow.
 */
public class DraftConsumerUncheckedException extends RuntimeException {

    private DraftConsumerUncheckedException(Throwable ex) {
        super(
                "Cannot produce immutable because an checked exception " +
                        "is raised in draft consumer lambda expression",
                ex
        );
        if (ex instanceof RuntimeException || ex instanceof Error) {
            throw new IllegalArgumentException(
                    "DraftConsumerUncheckedException cannot wrap RuntimeException or Error"
            );
        }
    }

    /**
     * 

* If the original exception is RuntimeException or Error, * throws it directly. *

* *

* Otherwise, throws a wrapper whose type is * {@link DraftConsumerUncheckedException} *

* * @param ex Original exception */ public static RuntimeException rethrow(Throwable ex) { if (ex instanceof RuntimeException) { throw (RuntimeException)ex; } if (ex instanceof Error) { throw (Error)ex; } throw new DraftConsumerUncheckedException(ex); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy