title: Future execution leads to unhandled exception
body: <pre><code>import 'dart:async';
  
  void main() {
    divide(1, 0).then((result) =&gt; print('1 / 0 = $result'))
      .catchError((error) =&gt; print('Error occured during division: $error'));
  }
  
  Future&lt;double&gt; divide(int a, b) {
    if (b == 0) {
      throw new Exception('Division by zero');
    }
    return new Future.value(a/b);
  }
  </code></pre>
  
  <p>Currently I am learning how to work with futures in Dart and I got stucked on such an easy example. My future throws exception when user tries to perform division by zero. However, .catchError doesn't handle my exception. I got unhandled exception with a stack trace instead. I'm pretty sure that I am missing something obvious but can't understand what exactly.</p>
  
  <p>As I understand, there is another way to handle error:</p>
  
  <pre><code>divide(1, 0).then((result) =&gt; print('1 / 0 = $result'),
      onError: (error) =&gt; print('Error occured during division: $error'));
  </code></pre>
  
  <p>to use named optional argument - <strong>onError</strong>. Doing like this still leads to unhandled exception.</p>
  
  <p>I would like to clarify one more thing. Am I right? - The only difference between these 2 approaches is that .catchError() also handles errors thrown by inner futures (futures that are called inside then() method of the outer future) while onError only catches errors thrown by the outer future?</p>
  
  <p>Dmitry</p>
  
  <p>Thank you.</p>