Interface ErrorMapper
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Service hook that replaces the error
HttpTransport derived from a failed response, for
vendor-specific mapping (for example a 403 that means bad credentials, or a 500 whose body says
the request will never succeed). Set it with TransportConfig.Builder.errorMapper.
The mapper runs for every response whose status the request does not accept, before the retry
decision and before Hooks.onError(codes.grow.packages.betterstack.core.Hooks.ErrorInfo), so hooks and callers see the mapped error. A mapped
error with retryable() == false stops the retries; a retryable one keeps the SPEC retry
rules of the status. The mapper must keep messages redacted: build them with HttpTransport.errorMessage(java.lang.String, int, java.util.Map<java.lang.String, java.util.List<java.lang.String>>, byte[], java.util.Collection<java.lang.String>) rather than from the raw body.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionmap(TransportResponse resp, BetterStackException error) Maps a failed response.
-
Field Details
-
NONE
Keeps the default error.
-
-
Method Details
-
map
Maps a failed response.- Parameters:
resp- the failed response (status, headers and the full body)error- the default error for the status- Returns:
- the error to raise, or
nullto keeperror
-