Package com.tnsai.llm.errors
Class ProviderErrorMappers
java.lang.Object
com.tnsai.llm.errors.ProviderErrorMappers
Static lookup facade for
ProviderErrorMappers registered via
ServiceLoader.
Provider clients call forProvider(String) when they catch
an HTTP error and need to convert it to a typed
LLMException. Mappers are loaded lazily
the first time the registry is consulted, then cached for the lifetime
of the JVM. Replacement is intentionally not supported — the SPI is the
configuration mechanism.
- Since:
- 0.5.0 (issue #87)
-
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<ProviderErrorMapper> forProvider(String providerId) static voidreload()Force a re-scan of the SPI.
-
Method Details
-
forProvider
- Parameters:
providerId- lowercase provider identifier (e.g."openai"); matched againstProviderErrorMapper.providerId()- Returns:
- the mapper for the given provider, or empty if no SPI implementation is registered
-
reload
public static void reload()Force a re-scan of the SPI. Primarily a test hook so unit tests can register mock mappers via a custom classloader and have them picked up. Production code should not need to call this.
-