Exception: Async::Stop

Inherits:
Exception
  • Object
show all
Defined in:
lib/async/stop.rb

Overview

Raised when a task is explicitly stopped.

Defined Under Namespace

Classes: Cause, Later

Instance Method Summary collapse

Constructor Details

#initialize(message = "Task was stopped") ⇒ Stop

Create a new stop operation.

This is a compatibility method for Ruby versions before 3.5 where cause is not propagated correctly when using Fiber#raise



43
44
45
46
47
48
49
50
# File 'lib/async/stop.rb', line 43

def initialize(message = "Task was stopped")
	if message.is_a?(Hash)
		@cause = message[:cause]
		message = "Task was stopped"
	end
	
	super(message)
end

Instance Method Details

#causeObject

This is a compatibility method for Ruby versions before 3.5 where cause is not propagated correctly when using Fiber#raise, we explicitly capture the cause here.



55
56
57
# File 'lib/async/stop.rb', line 55

def cause
	super || @cause
end