1
0
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:
Alexander Klingenbeck
2020-12-03 17:21:37 +01:00
committed by GitHub
parent 473392a56a
commit f5339993ce
4 changed files with 56 additions and 0 deletions

View File

@ -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**