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

reactivefeign.methodhandler.MonoMethodHandler Maven / Gradle / Ivy

package reactivefeign.methodhandler;

import org.reactivestreams.Publisher;
import reactor.core.publisher.Mono;

public class MonoMethodHandler implements MethodHandler {

	private final MethodHandler methodHandler;

	public MonoMethodHandler(MethodHandler methodHandler) {
		this.methodHandler = methodHandler;
	}

	@Override
	@SuppressWarnings("unchecked")
	public Mono invoke(final Object[] argv) {
		try {
			return Mono.from((Publisher)methodHandler.invoke(argv));
		} catch (Throwable throwable) {
			return Mono.error(throwable);
		}
	}
}