title: A better approach to handling exceptions in a functional way
body: <p>Exceptions, especially checked ones, can severely interrupt the flow of program logic when the FP idiom is used in Java 8. Here is an arbitrary example:</p>
  
  <pre><code>String s1 = "oeu", s2 = "2";
  Stream.of(s1, s2).forEach(s -&gt; 
      System.out.println(Optional.of(s).map(Integer::parseInt).get()));
  </code></pre>
  
  <p>The above code breaks when there's an exception for an unparseable string. But say I just want to replace that with a default value, much like I can with <code>Optional</code>:</p>
  
  <pre><code>Stream.of(s1, s2).forEach(s -&gt; 
     System.out.println(Optional.of(s)
                                .map(Integer::parseInt)
                                .orElse(-1)));
  </code></pre>
  
  <p>Of course, this still fails because <code>Optional</code> only handles <code>null</code>s. I would like something as follows:</p>
  
  <pre><code>Stream.of(s1, s2).forEach(s -&gt;
      System.out.println(
          Exceptional.of(s)
                     .map(Integer::parseInt)
                     .handle(NumberFormatException.class, swallow())
                     .orElse(-1)));
  </code></pre>
  
  <hr>
  
  <p><strong>Note:</strong> this is a self-answered question.</p>