Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 7f9eb24

Browse files
committed
Merge pull request #4 from butlermatt/master
Update try/catch syntax
2 parents fc97d6c + f2844d6 commit 7f9eb24

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/site/_includes/language-tour/exceptions/index.markdown

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Catching an exception gives you a chance to handle it.
4040
{% highlight dart %}
4141
try {
4242
breedMoreLlamas();
43-
} catch (final OutOfLlamasException e) {
43+
} on OutOfLlamasException catch (e) {
4444
buyMoreLlamas();
4545
}
4646
{% endhighlight %}
@@ -54,11 +54,11 @@ clause does not specify a type, that clause can handle any type of thrown object
5454
{% highlight dart %}
5555
try {
5656
breedMoreLlamas();
57-
} catch (final OutOfLlamasException e) { // A specific exception
57+
} on OutOfLlamasException catch (e) { // A specific exception
5858
buyMoreLlamas();
59-
} catch (final Exception e) { // Anything that is an exception
59+
} on Exception catch (e) { // Anything that is an exception
6060
print("Unknown exception: $e");
61-
} catch (final e) { // No specified type, handles all
61+
} catch (e) { // No specified type, handles all
6262
print("Something really unknown: $e");
6363
}
6464
{% endhighlight %}
@@ -85,7 +85,7 @@ The finally clause runs after any matching catch clauses.
8585
{% highlight dart %}
8686
try {
8787
breedMoreLlamas();
88-
} catch (final e) {
88+
} catch (e) {
8989
print("Error: $e"); // Handle exception first.
9090
} finally {
9191
cleanLlamaStalls(); // Then clean up.

0 commit comments

Comments
 (0)