1
0
forked from Mirror/wren

Fix example of catching and printing an error

The output didn't match the source code.
(Tested.)
This commit is contained in:
Brian Slesinsky
2015-01-02 14:12:53 -08:00
parent 6b510da872
commit 46867d3540

View File

@ -84,7 +84,7 @@ For example, if you run this program:
It prints:
:::text
Num does not implement method 'badMethod'.
Caught error: Num does not implement method 'badMethod'.
The called fiber can no longer be used, but any other fibers can proceed as usual. When a fiber has been aborted because of a runtime error, you can also get the error from the fiber object. Continuing the above example:
@ -115,4 +115,4 @@ Consider a program that reads in a string of input from the user and parses it t
For cases like this where failure can occur and the program *will* want to handle it, fibers and `try` are too coarse-grained to work with. Instead, these operations will indicate failure by *returning* some sort of error indication.
For example, a method for parsing a number could return a number on success and `null` to indicate parsing failed. Since Wren is dynamically typed, it's easy and natural for a method to return different types of values.
For example, a method for parsing a number could return a number on success and `null` to indicate parsing failed. Since Wren is dynamically typed, it's easy and natural for a method to return different types of values.