Class MiniMaxProviderErrorMapper
- All Implemented Interfaces:
ProviderErrorMapper
ProviderErrorMapper for MiniMax — twelfth pilot mapper.
MiniMax exposes two error envelopes depending on which endpoint failed; this mapper accepts both because the client (and partner-routed proxies in front of it) can hit either one:
- OpenAI-compatible at
/chat/completions— whatMiniMaxClientactually uses today:{ "error": { "message": "...", "type": "...", "code": "..." } } - Native at
/text/chatcompletion_v2— uses a numericbase_resp.status_codechannel:{ "base_resp": { "status_code": 1004, "status_msg": "..." } }
The native channel is non-trivial — MiniMax routes everything
through HTTP 200 even on failure, so the only signal is the JSON
status code. Mapper picks base_resp.status_code as the
canonical providerCode when present (stringified), else
falls back to the OpenAI code field.
Status mappings — native MiniMax codes (numeric):
1002(rate limit) /1039(TPM exceeded) → MODEL_OVERLOADED1004(auth failure) → AUTHENTICATION_FAILED1008(insufficient balance) → AUTHENTICATION_FAILED (same triage path — provisioning issue, not transient)1013(internal service) → SERVER_ERROR1027(output filter) /1042(prompt filter) → CONTENT_FILTERED1043/2013(invalid input/params) → INVALID_REQUEST1001(timeout) → SERVER_ERROR (transient)
OpenAI-compatible string codes are routed through the same
vocabulary the OpenAI mapper uses (rate_limit_exceeded,
invalid_api_key, context_length_exceeded, …).
Captured headers: retry-after, x-ratelimit-*,
x-request-id, x-trace-id (MiniMax surfaces a trace
id on most responses — useful for support tickets).
- Since:
- 0.5.3 (issue #87 follow-up — twelfth pilot mapper)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.tnsai.exceptions.LLMExceptionmap(int httpStatus, Map<String, String> responseHeaders, String responseBody, String model, Throwable cause) Translate a raw HTTP error response into a typedLLMException.Optional<com.tnsai.exceptions.LLMException.ErrorType> mapErrorType(String providerCode) Map a provider-native error code to a frameworkLLMException.ErrorType.
-
Constructor Details
-
MiniMaxProviderErrorMapper
public MiniMaxProviderErrorMapper()
-
-
Method Details
-
providerId
- Specified by:
providerIdin interfaceProviderErrorMapper- Returns:
- short, lowercase provider id (e.g.
"openai","anthropic"). Used to route a raw response to the right mapper.
-
map
public com.tnsai.exceptions.LLMException map(int httpStatus, Map<String, String> responseHeaders, String responseBody, String model, Throwable cause) Description copied from interface:ProviderErrorMapperTranslate a raw HTTP error response into a typedLLMException.- Specified by:
mapin interfaceProviderErrorMapper- Parameters:
httpStatus- HTTP status code from the responseresponseHeaders- selected response headers (lower-cased keys); empty map if none capturedresponseBody- raw response body; mapper parses provider-specific envelope (e.g. JSONerror.code)model- model identifier from the request, for the resultingLLMException.getModel()cause- underlying transport throwable, may be null when the failure is purely a non-2xx response- Returns:
- typed
LLMExceptionwithProviderDetailsattached
-
mapErrorType
Description copied from interface:ProviderErrorMapperMap a provider-native error code to a frameworkLLMException.ErrorType. Implementations should err on the side ofLLMException.ErrorType.UNKNOWNfor codes they don't recognize so that a new provider error doesn't fail the whole mapping path.- Specified by:
mapErrorTypein interfaceProviderErrorMapper- Parameters:
providerCode- native code (e.g."context_length_exceeded")- Returns:
- matching
LLMException.ErrorType, orOptional.empty()if the mapper has no opinion
-