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

Update try/catch syntax #4

Merged
merged 8 commits into from
Aug 30, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/site/_includes/language-tour/exceptions/index.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Catching an exception gives you a chance to handle it.
{% highlight dart %}
try {
breedMoreLlamas();
} catch (final OutOfLlamasException e) {
} on OutOfLlamasException catch (e) {
buyMoreLlamas();
}
{% endhighlight %}
Expand All @@ -54,11 +54,11 @@ clause does not specify a type, that clause can handle any type of thrown object
{% highlight dart %}
try {
breedMoreLlamas();
} catch (final OutOfLlamasException e) { // A specific exception
} on OutOfLlamasException catch (e) { // A specific exception
buyMoreLlamas();
} catch (final Exception e) { // Anything that is an exception
} on Exception catch (e) { // Anything that is an exception
print("Unknown exception: $e");
} catch (final e) { // No specified type, handles all
} catch (e) { // No specified type, handles all
print("Something really unknown: $e");
}
{% endhighlight %}
Expand All @@ -85,7 +85,7 @@ The finally clause runs after any matching catch clauses.
{% highlight dart %}
try {
breedMoreLlamas();
} catch (final e) {
} catch (e) {
print("Error: $e"); // Handle exception first.
} finally {
cleanLlamaStalls(); // Then clean up.
Expand Down