Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Fiber#raise

fiber.raise → obj
fiber.raise(string) → obj
fiber.raise(exception [, string [, array]]) → obj

Raises an exception in the fiber at the point at which the last Fiber.yield was called. If the fiber has not been started or has already run to completion, raises FiberError. If the fiber is yielding, it is resumed. If it is transferring, it is transferred into. But if it is resuming, raises FiberError.

With no arguments, raises a RuntimeError. With a single String argument, raises a RuntimeError with the string as a message. Otherwise, the first parameter should be the name of an Exception class (or an object that returns an Exception object when sent an exception message). The optional second parameter sets the message associated with the exception, and the third parameter is an array of callback information. Exceptions are caught by the rescue clause of begin...end blocks.

See also #inspect #resume #blocking? #storage also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0