title: What is an elegant way to wrap an error an rethrow in both cases?
body: <p>There is a method which can:</p>
  <ol>
  <li>throw an error</li>
  <li>return null</li>
  </ol>
  <p>I need to throw a user friendly exception to upper level in the both cases. What is the most elegant way for it? The brute force is:</p>
  <pre><code>try {
    result = callMethod();
  } catch (SomeException e) {
    throw new UserFiendlyException(&quot;cannot process you, try again pls&quot;);
  }
  if (result == null) {
    throw new UserFiendlyException(&quot;cannot process you, try again pls&quot;);
  }
  </code></pre>
  <p><strong>UPD 1</strong>: kotlin is accepted and preferable (but I'm also curious how could it be in Java)</p>
  <p><strong>UPD 2</strong>: Please, don't suggest <code>the use of exceptions for control flow is an anti-pattern</code>: <a href="https://softwareengineering.stackexchange.com/questions/189222/are-exceptions-as-control-flow-considered-a-serious-antipattern-if-so-why">https://softwareengineering.stackexchange.com/questions/189222/are-exceptions-as-control-flow-considered-a-serious-antipattern-if-so-why</a></p>