* Copyright (c) Huawei Technologies Co., Ltd. 2026. All rights reserved.
*/
#ifndef A2A_ERROR
#define A2A_ERROR
#include <nlohmann/json.hpp>
#include <stdexcept>
#include <string>
namespace A2A {
struct UnsupportedOperationError : public std::runtime_error {
using std::runtime_error::runtime_error;
};
struct A2AServerError : public std::runtime_error {
using std::runtime_error::runtime_error;
};
struct MethodNotImplementedError : public A2AServerError {
explicit MethodNotImplementedError(const std::string& message = "This method is not implemented by the server")
: A2AServerError("Not Implemented operation Error: " + message)
{
}
};
struct A2AClientHTTPError : public std::runtime_error {
int statusCode;
explicit A2AClientHTTPError(int code, const std::string& message)
: std::runtime_error("HTTP Error " + std::to_string(code) + ": " + message), statusCode(code)
{
}
};
struct A2AClientJSONError : public std::runtime_error {
explicit A2AClientJSONError(const std::string& message) : std::runtime_error("JSON Error: " + message)
{
}
};
struct A2AClientTimeoutError : public std::runtime_error {
explicit A2AClientTimeoutError(const std::string& message) : std::runtime_error("Timeout Error: " + message)
{
}
};
struct A2AClientJSONRPCError : public std::runtime_error {
nlohmann::json error;
explicit A2AClientJSONRPCError(const nlohmann::json& err)
: std::runtime_error("JSON-RPC Error: " + err.dump()), error(err)
{
}
};
}
#endif