Exception: Async::Cancel

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

Overview

Raised when a task is explicitly cancelled.

Defined Under Namespace

Classes: Cause, Later

Instance Method Summary collapse

Constructor Details

#initialize(message = "Task was cancelled") ⇒ Cancel

Create a new cancel operation.

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



40
41
42
43
44
45
46
47
48
# File 'lib/async/cancel.rb', line 40

def initialize(message = "Task was cancelled")
	
	if message.is_a?(Hash)
		@cause = message[:cause]
		message = "Task was cancelled"
	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.



53
54
55
# File 'lib/async/cancel.rb', line 53

def cause
	super || @cause
end