<pre class="language-dart"><code>// Synchronous code.
try {
  int value = foo();
  return bar(value);
} catch (e) {
  return 499;
}
</code></pre>
<p>Equivalent asynchronous code, based on futures:</p>
<pre class="language-dart"><code>Future&lt;int&gt; future = new Future(foo);  // Result of foo() as a future.
future.then((int value) =&gt; bar(value))
      .catchError((e) =&gt; 499);
</code></pre>
<p>Similar to the synchronous code, the error handler (registered with
<a href="dart-async/Future/catchError.ht