// Path: src/main/java/io/advantageous/reakt/exception/RejectedStreamException.java
// public class RejectedStreamException extends RuntimeException {
// 
//     public RejectedStreamException() {
//         super();
//     }
// 
//     public RejectedStreamException(String message) {
//         super(message);
//     }
// 
//     public RejectedStreamException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public RejectedStreamException(Throwable cause) {
//         super(cause);
//     }
// 
//     protected RejectedStreamException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
//         super(message, cause, enableSuppression, writableStackTrace);
//     }
// }
// 
// Path: src/main/java/io/advantageous/reakt/impl/StreamResultImpl.java
// public class StreamResultImpl<T> extends ResultImpl<T> implements StreamResult<T> {
//     private final boolean done;
//     private final Expected<Runnable> cancelCallback;
//     private final Expected<Consumer<Long>> requestMore;
// 
//     public StreamResultImpl(final Object object,
//                             final boolean done,
//                             final Expected<Runnable> cancelCallback,
//                             final Expected<Consumer<Long>> requestMore) {
//         super(object);
//         this.done = done;
//         this.cancelCallback = cancelCallback;
//         this.requestMore = requestMore;
//     }
// 
//     @Override
//     public boolean complete() {
//         return done;
//     }
// 
//     @Override
//     public void cancel() {
//         cancelCallback.ifPresent(Runnable::run);
//     }
// 
//     @Override
//     public void request(long n) {
//         requestMore.ifPresent(longConsumer -> longConsumer.accept(n));
//     }
// }


import io.advantageous.reakt.exception.RejectedStreamException;
import io.advantageous.reakt.impl.StreamResultImpl;
import java.util.function.Consumer;
     * This is a helper methods for producers (services that produce results) to send a failed result.
     *
     * @param errorMessage error message
     */
    default void fail(final String errorMessage) {
        this.onNext(new StreamResultImpl<>(
                new IllegalStateException(errorMessage), true, Expected.empty(), Expected.empty()));
    }


    /**
     * (Service view)
     * This allows services to send back a failed result easily to the client/handler.
     * This is a helper methods for producers (services that produce results) to send a failed result.
     *
     * @param error error
     */
    default void reject(final Throwable error) {
        this.onNext(new StreamResultImpl<>(error, true, Expected.empty(), Expected.empty()));
    }

    /**
     * (Service view)
     * This allows services to send back a failed result easily to the client/handler.
     * This is a helper methods for producers (services that produce results) to send a failed result.
     *
     * @param errorMessage error message
     */
    default void reject(final String errorMessage) {
        this.onNext(new StreamResultImpl<>(
// Path: src/main/java/io/advantageous/reakt/exception/RejectedStreamException.java
// public class RejectedStreamException extends RuntimeException {
// 
//     public RejectedStreamException() {
//         super();
//     }
// 
//     public RejectedStreamException(String message) {
//         super(message);
//     }
// 
//     public RejectedStreamException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public RejectedStreamException(Throwable cause) {
//         super(cause);
//     }
// 
//     protected RejectedStreamException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
//         super(message, cause, enableSuppression, writableStackTrace);
//     }
// }
// 
// Path: src/main/java/io/advantageous/reakt/impl/StreamResultImpl.java
// public class StreamResultImpl<T> extends ResultImpl<T> implements StreamResult<T> {
//     private final boolean done;
//     private final Expected<Runnable> cancelCallback;
//     private final Expected<Consumer<Long>> requestMore;
// 
//     public StreamResultImpl(final Object object,
//                             final boolean done,
//                             final Expected<Runnable> cancelCallback,
//                             final Expected<Consumer<Long>> requestMore) {
//         super(object);
//         this.done = done;
//         this.cancelCallback = cancelCallback;
//         this.requestMore = requestMore;
//     }
// 
//     @Override
//     public boolean complete() {
//         return done;
//     }
// 
//     @Override
//     public void cancel() {
//         cancelCallback.ifPresent(Runnable::run);
//     }
// 
//     @Override
//     public void request(long n) {
//         requestMore.ifPresent(longConsumer -> longConsumer.accept(n));
//     }
// }


// Path: src/main/java/io/advantageous/reakt/Stream.java
import io.advantageous.reakt.exception.RejectedStreamException;
import io.advantageous.reakt.impl.StreamResultImpl;
import java.util.function.Consumer;

     * This is a helper methods for producers (services that produce results) to send a failed result.
     *
     * @param errorMessage error message
     */
    default void fail(final String errorMessage) {
        this.onNext(new StreamResultImpl<>(
                new IllegalStateException(errorMessage), true, Expected.empty(), Expected.empty()));
    }


    /**
     * (Service view)
     * This allows services to send back a failed result easily to the client/handler.
     * This is a helper methods for producers (services that produce results) to send a failed result.
     *
     * @param error error
     */
    default void reject(final Throwable error) {
        this.onNext(new StreamResultImpl<>(error, true, Expected.empty(), Expected.empty()));
    }

    /**
     * (Service view)
     * This allows services to send back a failed result easily to the client/handler.
     * This is a helper methods for producers (services that produce results) to send a failed result.
     *
     * @param errorMessage error message
     */
    default void reject(final String errorMessage) {
        this.onNext(new StreamResultImpl<>(
                new RejectedStreamException(errorMessage), true, Expected.empty(), Expected.empty()));