mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-18 13:49:59 +01:00
fix #468
This commit is contained in:
@ -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.
|
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
|
## Failures
|
||||||
|
|
||||||
The last flavor of errors is the highest-level one. All of the above errors
|
The last flavor of errors is the highest-level one. All of the above errors
|
||||||
|
|||||||
@ -6,6 +6,14 @@ A lightweight coroutine. [Here][fibers] is a gentle introduction.
|
|||||||
|
|
||||||
## Static Methods
|
## 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**
|
### Fiber.**current**
|
||||||
|
|
||||||
The currently executing fiber.
|
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()
|
||||||
fiber.call("value") //> value
|
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**
|
### **isDone**
|
||||||
|
|
||||||
Whether the fiber's main function has completed and the fiber can no longer be
|
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**()
|
### **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**
|
**TODO**
|
||||||
|
|
||||||
### **transfer**(value)
|
### **transfer**(value)
|
||||||
|
|||||||
Reference in New Issue
Block a user