Package com.tnsai.llm.errors
Class AzureOpenAIProviderErrorMapper
java.lang.Object
com.tnsai.llm.errors.AzureOpenAIProviderErrorMapper
- All Implemented Interfaces:
ProviderErrorMapper
ProviderErrorMapper for Azure OpenAI Service — ninth pilot
mapper.
Azure OpenAI uses the same error envelope as OpenAI itself:
{ "error": { "message": "...", "type": "...", "code": "...", "param": "..." } }
The differences are operational, not envelope-
level: Azure-specific error conditions
(DeploymentNotFound, InvalidApiVersionParameter)
appear under the standard code field; the response carries
Azure correlation headers (x-ms-request-id,
apim-request-id) for tying requests to Azure portal log
traces.
Status mappings:
DeploymentNotFound(404) → MODEL_NOT_FOUND (Azure-specific: the deployed model name doesn't exist in this Azure resource)InvalidApiVersionParameter(400) → INVALID_REQUEST- OpenAI-shared codes inherit the same routing as
OpenAIProviderErrorMapper—rate_limit_exceeded→ MODEL_OVERLOADED,context_length_exceeded→ CONTEXT_TOO_LONG,invalid_api_key/Unauthorized→ AUTHENTICATION_FAILED, etc. - HTTP fallback for unrecognised codes
Captured headers: retry-after, x-ms-request-id,
apim-request-id, azureml-model-deployment.
- Since:
- 0.5.3 (issue #87 follow-up — ninth 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
-
AzureOpenAIProviderErrorMapper
public AzureOpenAIProviderErrorMapper()
-
-
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
-