Java Code Examples for rx.subjects.BehaviorSubject#onError()

The following examples show how to use rx.subjects.BehaviorSubject#onError() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebSocketService.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
private <T extends Notification<?>> void reportSubscriptionError(
        BehaviorSubject<T> subject, PlatonSubscribe subscriptionReply) {
    Response.Error error = subscriptionReply.getError();
    log.error("Subscription request returned error: {}", error.getMessage());
    subject.onError(
            new IOException(String.format(
                    "Subscription request failed with error: %s",
                    error.getMessage()
            ))
    );
}
 
Example 2
Source File: WebSocketService.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
private <T extends Notification<?>> void subscribeToEventsStream(
        Request request,
        BehaviorSubject<T> subject, Class<T> responseType) {

    subscriptionRequestForId.put(
            request.getId(),
            new WebSocketSubscription<>(subject, responseType));
    try {
        send(request, PlatonSubscribe.class);
    } catch (IOException e) {
        log.error("Failed to subscribe to RPC events with request id {}",
                request.getId());
        subject.onError(e);
    }
}