Class: A2A::TaskNotCancelableError

Inherits:
JSONRPC::Error
  • Object
show all
Defined in:
lib/a2a/types/task_not_cancelable_error.rb

Overview

Error non-cancelable tasks (-32002)

Raised when a task cannot be canceled. An attempt was made to cancel a task that is not in a cancelable state (e.g., it has already reached a terminal state like completed, failed, or canceled).

Examples:

Create a task not cancelable error

error = JSONRPC::Errors::TaskNotCancelableError.new

Instance Method Summary collapse

Constructor Details

#initialize(message = 'Task cannot be canceled.', data: nil, request_id: nil) ⇒ TaskNotCancelableError

Creates a new Task Not Cancelable Error with code -32002

Examples:

Create a task not cancelable error with default message

error = JSONRPC::TaskNotCancelableError.new

Create a task not cancelable error with exception details

error = JSONRPC::TaskNotCancelableError.new(data: { exception: 'Task reached terminal state' }, request_id: 1)

Parameters:

  • message (String) (defaults to: 'Task cannot be canceled.')

    short description of the error

  • data (Hash, Array, String, Number, Boolean, nil) (defaults to: nil)

    additional error information

  • request_id (String, Integer, nil) (defaults to: nil)

    the request identifier



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/a2a/types/task_not_cancelable_error.rb', line 29

def initialize(
  message = 'Task cannot be canceled.',
  data: nil,
  request_id: nil
)
  super(
    message,
    code: ErrorCodes::TASK_NOT_CANCELABLE,
    data:,
    request_id:
  )
end