To ensure predictable error handling and parsing across all microservices, Hoox enforces a strict response contract. Every worker responds with a standardized JSON envelope containing tracing details, operation status, results payload, and detailed error models.
This document details the exact JSON templates, types, and error factories utilized in the monorepo.
🛡️ 1. Standard Response Envelope
Every HTTP response returned by an edge worker is encapsulated within a unified JSON envelope:
🏆 2. Success Response Templates
A. Trade Execution Fill Success (trade-worker - 200 OK)
B. Telegram Push Success (telegram-worker - 200 OK)
🚨 3. Error Models & Edge Error Codes
When a worker operation fails, the success flag is set to false, the result field is omitted or set to null, and the error model is fully populated:
A. 400 Bad Request (JSON Validation Error)
B. 409 Conflict (Idempotency Mutex Intercept)
🛠️ 4. Shared Errors Factory Middleware
To enforce this response contract without writing redundant JSON wrappers in every worker, we use the standardized Errors factory from the shared monorepo package @jango-blockchained/hoox-shared/errors:
These factory methods automatically serialize the exception, attach the active requestId from the context, set the correct HTTP status code, and return a compliant Response object.
🔗 Next Steps
Last modified on June 17, 2026