forked from Mirror/wren
Add support for Fiber.try(_) (#835)
* Add support for Fiber.try(_) * Add documentation for Fiber.try(_) * Add another test for Fiber.try(_)
This commit is contained in:
committed by
GitHub
parent
473392a56a
commit
f5339993ce
@ -174,6 +174,24 @@ System.print("Caught error: " + error)
|
||||
|
||||
If the called fiber raises an error, it can no longer be used.
|
||||
|
||||
### **try**(value)
|
||||
Tries to run the fiber. If a runtime error occurs
|
||||
in the called fiber, the error is captured and is returned as a string.
|
||||
If the fiber is being
|
||||
started for the first time, and its function takes a parameter, `value` is
|
||||
passed to it.
|
||||
|
||||
<pre class="snippet">
|
||||
var fiber = Fiber.new {|value|
|
||||
value.badMethod
|
||||
}
|
||||
|
||||
var error = fiber.try("just a string")
|
||||
System.print("Caught error: " + error)
|
||||
</pre>
|
||||
|
||||
If the called fiber raises an error, it can no longer be used.
|
||||
|
||||
### **transfer**()
|
||||
|
||||
**TODO**
|
||||
|
||||
Reference in New Issue
Block a user