Errors (C++)
The C++ SDK keeps three error types separate. HostError means the application could not start or shut down. ActionError is what a handler returns when an invocation fails. ProtocolError is the JSON-RPC error object that crosses the connection.
Protocol error codes
Section titled “Protocol error codes”TesseronErrorCode is the closed set of protocol codes. to_wire_code(...) returns the JSON-RPC integer, and from_wire_code(...) returns std::nullopt for an integer this SDK does not define.
| Code | Enumerator | When |
|---|---|---|
-32700 | ParseError | The peer sent bytes that are not valid JSON. |
-32600 | InvalidRequest | The envelope is not a valid JSON-RPC 2.0 message. |
-32601 | MethodNotFound | The requested method is not part of the Tesseron protocol. |
-32602 | InvalidParams | Method parameters do not match the documented shape, including an elicit schema MCP cannot render. |
-32603 | InternalError | An unexpected failure occurred. Detail stays local. |
-32000 | ProtocolMismatch | The host and gateway disagree on the protocol major version. |
-32001 | Cancelled | The agent cancelled the invocation. |
-32002 | Timeout | The invocation passed its action timeout. |
-32003 | ActionNotFound | No action is registered under the requested name, or a resource is not readable or subscribable. |
-32004 | InputValidation | The invocation input failed the action's declared schema. |
-32005 | HandlerError | The handler reported a domain failure. |
-32006 | SamplingNotAvailable | The agent did not negotiate sampling. |
-32007 | ElicitationNotAvailable | The agent did not negotiate elicitation. |
-32008 | SamplingDepthExceeded | The gateway's sampling-depth limit was exceeded. |
-32009 | Unauthorized | The session is unclaimed or the operation is not permitted. |
-32010 | TransportClosed | The transport closed while a request was in flight. |
-32011 | ResumeFailed | The gateway refused the resume credentials. |
Result and ActionError
Section titled “Result and ActionError”Handlers return boost::asio::awaitable<Result<Json>>. Startup returns Result<Host, HostError>, and shutdown returns Result<void, HostError>. A handler can return a domain failure through ActionError::handler(message), a chosen code through ActionError::protocol(code, message, data), or a local cause through ActionError::internal(source).
The todo example's helper returns -32005 HandlerError with data when an id is unknown:
ActionError todo_not_found() { return ActionError::protocol(tesseron::TesseronErrorCode::HandlerError, "Todo not found", Json{{"kind", "not_found"}});}The toggleTodo and deleteTodo handlers co_return todo_not_found() when their lookup reaches the end. Use ActionError::handler(message) for the same -32005 code without custom data. Use ActionError::protocol(code, message, data) when the agent needs a specific code and structured detail. Use ActionError::internal(source) when the failure is a bug rather than a domain outcome. Its cause stays local and the agent receives -32603 Internal error. A handler that throws is treated the same way.
ProtocolError
Section titled “ProtocolError”ProtocolError represents the JSON-RPC error member with an integer code, a message, and optional JSON data. The integer stays available even when it is outside TesseronErrorCode, so a newer gateway's code can round-trip. named_code() returns std::nullopt for that unknown integer.
Construct it with either a TesseronErrorCode or a raw integer. with_data(...) attaches structured detail, to_json() makes the wire payload, and from_json(...) reads one when the shape is valid.
Envelope errors
Section titled “Envelope errors”The host follows the wire-format rules for request IDs. An id: null member still marks a request, and its response carries id: null. Only an absent id makes a notification, so a notification receives no response.
A frame without jsonrpc: "2.0" receives -32600 InvalidRequest. The host carries through a usable string, number, or null id, and uses null when there is no usable id. The session stays up after this response and can process the next frame.
HostError
Section titled “HostError”These errors happen before an invocation reaches a handler:
| Kind | When |
|---|---|
MissingApplication | No application was registered before listen(). |
InvalidApplicationId | The application id is reserved or fails ^[a-z][a-z0-9_]*$. |
DuplicateName | Two actions or two resources use the same name. |
NonLoopbackBindAddress | bind_address was given a non-loopback address. |
Listen | The loopback listener could not bind. |
Manifest | The instance manifest could not be written or removed. |
HomeDirectoryUnknown | The home directory for ~/.tesseron could not be resolved. |
listen() refuses a non-loopback address before binding. shutdown() reports manifest removal failures through Result<void, HostError>.