1
0
forked from Mirror/wren
This commit is contained in:
aaronduino
2017-09-16 21:38:35 -07:00
parent d390e16a99
commit 16bab57056
2 changed files with 35 additions and 0 deletions

View File

@ -144,6 +144,8 @@ to cause your own runtime errors to occur. This can be done by calling the
You must pass in an error message, and it must be a string.
If the provided message is `null`, no runtime error is raised.
## Failures
The last flavor of errors is the highest-level one. All of the above errors

View File

@ -6,6 +6,14 @@ A lightweight coroutine. [Here][fibers] is a gentle introduction.
## Static Methods
### Fiber.**abort**(message)
Raises a runtime error with the provided message, unless `message` is `null`
:::wren
Fiber.abort(null) // Do nothing.
Fiber.abort("Something bad happened") // Raise a runtime error with provided messsage.
### Fiber.**current**
The currently executing fiber.
@ -127,6 +135,17 @@ Invokes the fiber or resumes the fiber if it is in a paused state and sets
fiber.call()
fiber.call("value") //> value
### **error***
Assuming that a fiber has raised an error, `error` returns the error message.
:::wren
var fiber = Fiber.new {
123.badMethod
}
fiber.try()
System.print(fiber.error) //> Num does not implement method 'badMethod'.
### **isDone**
Whether the fiber's main function has completed and the fiber can no longer be
@ -134,6 +153,20 @@ run. This returns `false` if the fiber is currently running or has yielded.
### **transfer**()
### **try**()
Tries to run the fiber. If a runtime error occurs
in the called fiber, the error is captured and is returned as a string.
:::wren
var fiber = Fiber.new {
123.badMethod
}
var error = fiber.try()
System.print("Caught error: " + error)
If the called fiber raises an error, it can no longer be used.
**TODO**
### **transfer**(value)