Search in sources :

Example 16 with HystrixBadRequestException

use of com.netflix.hystrix.exception.HystrixBadRequestException in project Hystrix by Netflix.

the class GenericObservableCommand method construct.

/**
 *{@inheritDoc}.
 */
@Override
protected Observable construct() {
    Observable result;
    try {
        Observable observable = toObservable(commandActions.getCommandAction().execute(executionType));
        result = observable.onErrorResumeNext(new Func1<Throwable, Observable>() {

            @Override
            public Observable call(Throwable throwable) {
                if (isIgnorable(throwable)) {
                    return Observable.error(new HystrixBadRequestException(throwable.getMessage(), throwable));
                }
                return Observable.error(throwable);
            }
        });
        flushCache();
    } catch (CommandActionExecutionException throwable) {
        Throwable cause = throwable.getCause();
        if (isIgnorable(cause)) {
            throw new HystrixBadRequestException(cause.getMessage(), cause);
        }
        throw throwable;
    }
    return result;
}
Also used : HystrixBadRequestException(com.netflix.hystrix.exception.HystrixBadRequestException) CommandActionExecutionException(com.netflix.hystrix.contrib.javanica.exception.CommandActionExecutionException) Func1(rx.functions.Func1) Observable(rx.Observable)

Aggregations

HystrixBadRequestException (com.netflix.hystrix.exception.HystrixBadRequestException)16 HystrixRuntimeException (com.netflix.hystrix.exception.HystrixRuntimeException)8 TestCircuitBreaker (com.netflix.hystrix.HystrixCircuitBreakerTest.TestCircuitBreaker)7 ExecutionException (java.util.concurrent.ExecutionException)6 TimeoutException (java.util.concurrent.TimeoutException)6 Test (org.junit.Test)6 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)5 IOException (java.io.IOException)4 CommandActionExecutionException (com.netflix.hystrix.contrib.javanica.exception.CommandActionExecutionException)2 HystrixTimeoutException (com.netflix.hystrix.exception.HystrixTimeoutException)2 ByteBuf (io.netty.buffer.ByteBuf)2 HashMap (java.util.HashMap)2 Observable (rx.Observable)2 Action0 (rx.functions.Action0)2 Func1 (rx.functions.Func1)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 MockResponse (com.google.mockwebserver.MockResponse)1 MockWebServer (com.google.mockwebserver.MockWebServer)1 HystrixInvokable (com.netflix.hystrix.HystrixInvokable)1 HystrixCollapser (com.netflix.hystrix.contrib.javanica.annotation.HystrixCollapser)1