@@ -393,27 +393,35 @@ class Fiber < Object
393393
394394 # <!--
395395 # rdoc-file=cont.c
396- # - fiber.raise -> obj
397- # - fiber.raise(string) -> obj
398- # - fiber.raise(exception [, string [, array]]) -> obj
396+ # - raise(exception, message = exception.to_s, backtrace = nil, cause: $!)
397+ # - raise(message = nil, cause: $!)
399398 # -->
400399 # Raises an exception in the fiber at the point at which the last `Fiber.yield`
401- # was called. If the fiber has not been started or has already run to
402- # completion, raises `FiberError`. If the fiber is yielding, it is resumed. If
403- # it is transferring, it is transferred into. But if it is resuming, raises
404- # `FiberError`.
405- #
406- # With no arguments, raises a `RuntimeError`. With a single `String` argument,
407- # raises a `RuntimeError` with the string as a message. Otherwise, the first
408- # parameter should be the name of an `Exception` class (or an object that
409- # returns an `Exception` object when sent an `exception` message). The optional
410- # second parameter sets the message associated with the exception, and the third
411- # parameter is an array of callback information. Exceptions are caught by the
412- # `rescue` clause of `begin...end` blocks.
400+ # was called.
401+ #
402+ # f = Fiber.new {
403+ # puts "Before the yield"
404+ # Fiber.yield 1 # -- exception will be raised here
405+ # puts "After the yield"
406+ # }
407+ #
408+ # p f.resume
409+ # f.raise "Gotcha"
410+ #
411+ # Output
412+ #
413+ # Before the first yield
414+ # 1
415+ # t.rb:8:in 'Fiber.yield': Gotcha (RuntimeError)
416+ # from t.rb:8:in 'block in <main>'
417+ #
418+ # If the fiber has not been started or has already run to completion, raises
419+ # `FiberError`. If the fiber is yielding, it is resumed. If it is transferring,
420+ # it is transferred into. But if it is resuming, raises `FiberError`.
413421 #
414422 # Raises `FiberError` if called on a Fiber belonging to another `Thread`.
415423 #
416- # See Kernel#raise for more information.
424+ # See Kernel#raise for more information on arguments .
417425 #
418426 def raise : (?string msg, ?cause: Exception?) -> untyped
419427 | (_Exception, ?string msg, ?Array[string] | Array[Thread::Backtrace::Location] | nil backtrace, ?cause: Exception?) -> untyped
0 commit comments