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

io.github.vipcxj.jasync.spec.catcher.Catcher Maven / Gradle / Ivy

Go to download

JAsync implements Async-Await fashion for Java just like es and c#. This library provide the spec of all public api.

There is a newer version: 1.0.17
Show newest version
package io.github.vipcxj.jasync.spec.catcher;

import io.github.vipcxj.jasync.spec.functional.PromiseFunction;

public class Catcher {

    private final Class exceptionType;
    private final PromiseFunction reject;

    public Catcher(Class exceptionType, PromiseFunction function) {
        this.exceptionType = exceptionType;
        this.reject = function;
    }

    public boolean match(Throwable t) {
        return t != null && exceptionType.isAssignableFrom(t.getClass());
    }

    public Class getExceptionType() {
        return exceptionType;
    }

    public PromiseFunction getReject() {
        return reject;
    }

    public static  Catcher of(Class exceptionType, PromiseFunction function) {
        return new Catcher<>(exceptionType, function);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy