Exception: A2A::TaskNotCancelableError

Inherits:
Error
  • Object
show all
Defined in:
lib/a2a/errors.rb

Overview

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).

Instance Attribute Summary

Attributes inherited from Error

#code, #http_status

Instance Method Summary collapse

Methods inherited from Error

#to_h

Constructor Details

#initialize(task_id, state:, message: "Task is not cancelable") ⇒ TaskNotCancelableError

Returns a new instance of TaskNotCancelableError.



76
77
78
79
80
# File 'lib/a2a/errors.rb', line 76

def initialize(task_id, state:, message: "Task is not cancelable")
  @task_id = task_id
  @state   = state
  super(message, code: -32002, http_status: 400)
end

Instance Method Details

#error_dataObject



82
83
84
85
86
87
88
89
# File 'lib/a2a/errors.rb', line 82

def error_data
  [{
    "@type"    => "type.googleapis.com/google.rpc.ErrorInfo",
    "reason"   => "TASK_NOT_CANCELABLE",
    "domain"   => "a2a-protocol.org",
    "metadata" => { "taskId" => @task_id.to_s, "state" => @state.to_s },
  }]
end