Where is the best place to capture and log errors and exceptions, below is what I current have ?
Do I need to capture and re-throw anything from the fallBack() method, or will the HystrixRuntimeException be sufficient ?
Are there any documents which explain what causes these exceptions (like COMMAND_EXCEPTION) to be thrown ?
HystrixCommand hystrixCommand = new HystrixCommand(HystrixCommand.Setter
.withGroupKey(HystrixCommandGroupKey.Factory.asKey(commandGroupName))
.andCommandKey(HystrixCommandKey.Factory.asKey(commandKeyName))) {
@Override
protected Collection<RouteInfo> run() {
Collection<RouteInfo> routes;
try {
routes = searchVehicles(request, endPointConfigurationMap, rateCodeConfiguration);
calculateAndSetValidUntil(routes, request);
return routes;
} catch (ErrorPricingEndPointBeanException | EndPointException | DateFormatException | ConfigurationException | XmlParseException e) {
throw new HystrixBadRequestException(e.getMessage(), e);
}
}
try {
HystrixCommand hystrixCommand = supplierSearchViaHystrix(hystrixConfiguration, request, endPointConfigurationMap, rateCodeConfiguration);
return (Collection<RouteInfo>) hystrixCommand.execute();
} catch (HystrixBadRequestException e) {
if (e.getCause() instanceof ErrorPricingEndPointBeanException) {
throw new ErrorPricingEndPointBeanException(((ErrorPricingEndPointBeanException) e.getCause()).getErrorType(), e.getMessage());
} else if (e.getCause() instanceof EndPointException) {
throw new EndPointException(e.getCause().getMessage(), e.getCause());
} else if (e.getCause() instanceof DateFormatException) {
throw new DateFormatException(e.getCause().getMessage(), e.getCause());
} else if (e.getCause() instanceof ConfigurationException) {
throw new ConfigurationException(e.getCause().getMessage(), e.getCause());
} else if (e.getCause() instanceof XmlParseException) {
throw new XmlParseException(e.getCause().getMessage(), e.getCause());
}
} catch (HystrixRuntimeException e) {
LOG.debug("--------------- HYSTRIX RTEX {} {}"+ e.getFailureType().name(), e.getFallbackException().getCause());
throw new EndPointInterruptedException(EndPointBeanInterruptionError.valueOf(e.getFailureType().name()));
}
Many thanks.