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

com.englishtown.promises.exceptions.RejectException Maven / Gradle / Ivy

There is a newer version: 3.1.1
Show newest version
package com.englishtown.promises.exceptions;

import java.util.ArrayList;
import java.util.List;

/**
 * Exception thrown when rejecting.  Contains inner exceptions and an optional rejection value
 */
public class RejectException extends RuntimeException {

    private final List innerExceptions = new ArrayList<>();
    private Object value;

    public RejectException() {
    }

    public RejectException(String message) {
        super(message);
    }

    public RejectException(String message, Throwable cause) {
        super(message, cause);
        addInnerException(cause);
    }

    public RejectException(String message, List innerExceptions) {
        super(message);
        if (innerExceptions != null) {
            this.innerExceptions.addAll(innerExceptions);
        }
    }

    public RejectException addInnerException(Throwable inner) {
        if (inner != null) {
            innerExceptions.add(inner);
        }
        return this;
    }

    public List getInnerExceptions() {
        return innerExceptions;
    }

    public RejectException setValue(Object value) {
        this.value = value;
        return this;
    }

    @SuppressWarnings("unchecked")
    public  T getValue() {
        return (T) this.value;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy