mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 05:29:10 +02:00

* Add support for `cause:` argument to `Fiber#raise` and `Thread#raise`. The implementation behaviour is consistent with `Kernel#raise` and `Exception#initialize` methods, allowing the `cause:` argument to be passed to `Fiber#raise` and `Thread#raise`. This change ensures that the `cause:` argument is handled correctly, providing a more consistent and expected behavior when raising exceptions in fibers and threads. [Feature #21360] * Shared specs for Fiber/Thread/Kernel raise. --------- Co-authored-by: Samuel Williams <samuel.williams@shopify.com>
22 lines
373 B
Ruby
22 lines
373 B
Ruby
module FiberSpecs
|
|
|
|
class NewFiberToRaise
|
|
def self.raise(*args, **kwargs, &block)
|
|
fiber = Fiber.new do
|
|
if block_given?
|
|
block.call do
|
|
Fiber.yield
|
|
end
|
|
else
|
|
Fiber.yield
|
|
end
|
|
end
|
|
|
|
fiber.resume
|
|
|
|
fiber.raise(*args, **kwargs)
|
|
end
|
|
end
|
|
|
|
class CustomError < StandardError; end
|
|
end
|