e = executionHook.onError(_cmd, failureType, e);
} catch (Exception hookException) {
logger.warn("Error calling ExecutionHook.onError", hookException);
}
return Observable.error(new HystrixRuntimeException(failureType, _cmd.getClass(), getLogMessagePrefix() + " " + message + " and no fallback available.", e, fe));
} else {
logger.debug("HystrixCommand execution " + failureType.name() + " and fallback retrieval failed.", fe);
metrics.markFallbackFailure();
// record the executionResult
executionResult = executionResult.addEvents(HystrixEventType.FALLBACK_FAILURE);
/* executionHook for all errors */
try {
e = executionHook.onError(_cmd, failureType, e);
} catch (Exception hookException) {
logger.warn("Error calling ExecutionHook.onError", hookException);
}
return Observable.error(new HystrixRuntimeException(failureType, _cmd.getClass(), getLogMessagePrefix() + " " + message + " and failed retrieving fallback.", e, fe));
}
}
}).doOnTerminate(new Action0() {
@Override
public void call() {
// record that we're completed (to handle non-successful events we do it here as well as at the end of executeCommand
isExecutionComplete.set(true);
}
}).doOnEach(new Action1<Notification<? super R>>() {
@Override
public void call(Notification<? super R> n) {
setRequestContextIfNeeded(currentRequestContext);
}
});
} else {
/* fallback is disabled so throw HystrixRuntimeException */
Exception e = originalException;
logger.debug("Fallback disabled for HystrixCommand so will throw HystrixRuntimeException. ", e); // debug only since we're throwing the exception and someone higher will do something with it
// record the executionResult
executionResult = executionResult.addEvents(eventType);
/* executionHook for all errors */
try {
e = executionHook.onError(this, failureType, e);
} catch (Exception hookException) {
logger.warn("Error calling ExecutionHook.onError", hookException);
}
return Observable.<R> error(new HystrixRuntimeException(failureType, this.getClass(), getLogMessagePrefix() + " " + message + " and fallback disabled.", e, null)).doOnTerminate(new Action0() {
@Override
public void call() {
// record that we're completed (to handle non-successful events we do it here as well as at the end of executeCommand
isExecutionComplete.set(true);