feat: add Fiber.abort() method to abort fiber with error message
Implements a new `Fiber.abort()` static method that allows a fiber to terminate with a custom error message string. The method validates that the argument is a string, then returns a PRIM_ERROR to abort the current fiber. Includes three test cases: basic abort with error message retrieval via `fiber.try`, aborting the main fiber with a runtime error, and type checking that non-string arguments produce an appropriate error message.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
var fiber = new Fiber {
|
||||
Fiber.abort("Error message.")
|
||||
}
|
||||
|
||||
IO.print(fiber.try) // expect: Error message.
|
||||
IO.print(fiber.isDone) // expect: true
|
||||
IO.print(fiber.error) // expect: Error message.
|
||||
@@ -0,0 +1 @@
|
||||
Fiber.abort("Abort!") // expect runtime error: Abort!
|
||||
@@ -0,0 +1 @@
|
||||
Fiber.abort(123) // expect runtime error: Error message must be a string.
|
||||
Reference in New Issue
Block a user