class ReactorExt {

    public static Mono<Optional<Throwable>> emitError(Mono<?> source) {
        return source.ignoreElement().materialize().map(result ->
                result.getType() == SignalType.ON_ERROR
                        ? Optional.of(result.getThrowable())
                        : Optional.empty()
        );
    }

    private  ReactorExt();

}