title: How to properly handle expected errors in Hystrix fallback?
body: <p>We have a Hystrix (1.4.x) command that looks like this (using Spring):</p>
  <pre><code>@HystrixCommand(groupKey = &quot;GroupKey&quot;, commandKey = &quot;CommandKey&quot;, fallbackMethod = &quot;myFallback&quot;)
  public List&lt;X&gt; findXs(long xId) {
     return externalService.findXsExternally(xId);
  }
  </code></pre>
  <p>We actually don't want to return a (empty) <code>List</code> from the fallback method but rather throw an exception so that we caller of <code>findXs</code> knows that the <code>externalService</code> is down and can take action accordingly. But at the same time we would like to take advantage of the functionality that Hystrix provides.</p>
  <p>In our case we want the caller to return an error message instead of returning a list. In Spring a fallback is implemented like this:</p>
  <pre><code>public List&lt;X&gt; myFallback(long xId) {
      // What to do?? Throw exception!?  
  }
  </code></pre>
  <p>Throwing an exception from <code>myFallback</code> &quot;works&quot; but Hystrix will warn us that:</p>
  <blockquote>
  <p>CommandKey failed and fallback failed.</p>
  </blockquote>
  <p>I.e. it will interpret this as a fallback failure. In our case the exception should <em>not</em> be interpreted as a fallback failure but rather as expected behavior. We've also tried wrapping the thrown exception in a <code>HystrixBadRequestException</code> but it doesn't seem to work for fallbacks (according to the <a href="https://github.com/Netflix/Hystrix/wiki/How-To-Use#error-propagation" rel="nofollow noreferrer">docs</a> this would work for the &quot;run&quot; method).</p>
  <p>How would one implement an exception-throwing <em>fallback method</em> in Hystrix? Can we safely ignore the warning or is Hystrix not designed work this way?</p>