Package org.a2aproject.sdk.spec
Class TaskNotCancelableError
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.a2aproject.sdk.spec.A2AError
org.a2aproject.sdk.spec.A2AProtocolError
org.a2aproject.sdk.spec.TaskNotCancelableError
- All Implemented Interfaces:
Serializable,Event
A2A Protocol error indicating that a task cannot be canceled in its current state.
This error is returned when a client attempts to cancel a task
but the task is in a terminal state (TaskState.TASK_STATE_COMPLETED, TaskState.TASK_STATE_FAILED,
TaskState.TASK_STATE_CANCELED) where cancellation is not applicable.
Tasks can only be canceled when they are in non-terminal states such as TaskState.TASK_STATE_SUBMITTED
or TaskState.TASK_STATE_WORKING.
Corresponds to A2A-specific error code -32002.
Usage example:
Task task = taskStore.getTask(taskId);
if (task.status().state().isFinal()) {
throw new TaskNotCancelableError(
"Task in " + task.status().state() + " state cannot be canceled"
);
}
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs error with default message.TaskNotCancelableError(@Nullable Integer code, @Nullable String message, @Nullable Map<String, Object> details) Constructs error with all parameters.TaskNotCancelableError(String message) Constructs error with custom message. -
Method Summary
Methods inherited from class org.a2aproject.sdk.spec.A2AError
getCode, getDetailsMethods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
TaskNotCancelableError
public TaskNotCancelableError()Constructs error with default message. -
TaskNotCancelableError
public TaskNotCancelableError(@Nullable Integer code, @Nullable String message, @Nullable Map<String, Object> details) Constructs error with all parameters.- Parameters:
code- the error code (defaults to -32002 if null)message- the error message (defaults to "Task cannot be canceled" if null)details- additional error details (optional)
-
TaskNotCancelableError
Constructs error with custom message.- Parameters:
message- the error message
-