Package io.a2a.spec

Class A2AError

All Implemented Interfaces:
Event, Serializable
Direct Known Subclasses:
A2AProtocolError, InternalError, InvalidParamsError, InvalidRequestError, JSONParseError, MethodNotFoundError

public class A2AError extends RuntimeException implements Event
Marker interface for A2A Protocol error events.

This interface extends Event to allow errors to be transmitted as events in the A2A Protocol's event stream. All protocol-level errors implement this interface, enabling uniform error handling across both streaming and non-streaming communication.

A2A errors typically extend A2AError to provide JSON-RPC 2.0 compliant error responses with standard error codes, messages, and optional additional data.

Common implementations include:

See Also:
  • Constructor Details

    • A2AError

      public A2AError(Integer code, String message, @Nullable Object data)
      Constructs a JSON-RPC error with the specified code, message, and optional data.

      This constructor is used by Jackson for JSON deserialization.

      Parameters:
      code - the numeric error code (required, see JSON-RPC 2.0 spec for standard codes)
      message - the human-readable error message (required)
      data - additional error information, structure defined by the error code (optional)
      Throws:
      IllegalArgumentException - if code or message is null
  • Method Details

    • getCode

      public Integer getCode()
      Gets the numeric error code indicating the error type.

      Standard JSON-RPC 2.0 error codes:

      • -32700: Parse error
      • -32600: Invalid Request
      • -32601: Method not found
      • -32602: Invalid params
      • -32603: Internal error
      • -32000 to -32099: Server error (implementation-defined)
      Returns:
      the error code
    • getData

      public @Nullable Object getData()
      Gets additional information about the error.

      The structure and type of the data field is defined by the specific error code. It may contain detailed debugging information, validation errors, or other context-specific data to help diagnose the error.

      Returns:
      the error data, or null if not provided