Package codes.grow.packages.betterstack
Class BetterStackErrors
java.lang.Object
codes.grow.packages.betterstack.BetterStackErrors
Better Stack specific error mapping on top of the SPEC section 2.1 HTTP mapping.
- Ingest host:
403(invalid or missing source token) becomesAuthenticationException;402(quota or spending limit) becomes a non-retryableQuotaExceededException;406/413stayValidationException. - SQL host: the ClickHouse exception code (
Code: 60. DB::Exception: …) wins over the HTTP status: 516/192/193/194 authentication, 497 permission denied, 60/81 not found, 62/47/46/36/53/42/73/456/457/241 validation, 48 unsupported, 159/160 timeout, 202 rate limited (retryable).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringHint appended to ClickHouseMEMORY_LIMIT_EXCEEDED(241) errors. -
Method Summary
Modifier and TypeMethodDescriptionstatic OptionalIntclickHouseCode(String text) Extracts the ClickHouse exception code from an error text (Code: 60. DB::Exception: …).static Optional<BetterStackException> errorForClickHouseCode(int code, String message, Integer httpStatus, String requestId) Builds the SDK exception for a ClickHouse exception code, or empty when the code has no specific mapping (the HTTP status mapping applies then).static BetterStackExceptionmapIngestError(Throwable error, String operation) Maps an ingest-host failure (see the class description).static BetterStackExceptionmapQueryError(Throwable error, String operation) Maps a SQL-host failure by the ClickHouse code found in its message; otherwise the error is returned unchanged.
-
Field Details
-
MEMORY_HINT
Hint appended to ClickHouseMEMORY_LIMIT_EXCEEDED(241) errors.- See Also:
-
-
Method Details
-
mapIngestError
Maps an ingest-host failure (see the class description). Other errors are returned unchanged.- Parameters:
error- failure (may be wrapped in aCompletionException)operation- operation name for non-SDK failures- Returns:
- the mapped SDK exception
-
clickHouseCode
Extracts the ClickHouse exception code from an error text (Code: 60. DB::Exception: …).- Parameters:
text- error text, may be null- Returns:
- the code, or empty
-
errorForClickHouseCode
public static Optional<BetterStackException> errorForClickHouseCode(int code, String message, Integer httpStatus, String requestId) Builds the SDK exception for a ClickHouse exception code, or empty when the code has no specific mapping (the HTTP status mapping applies then).- Parameters:
code- ClickHouse exception codemessage- redacted messagehttpStatus- HTTP status ornullrequestId- request id ornull- Returns:
- the exception, or empty
-
mapQueryError
Maps a SQL-host failure by the ClickHouse code found in its message; otherwise the error is returned unchanged.- Parameters:
error- failure (may be wrapped)operation- operation name for non-SDK failures- Returns:
- the mapped SDK exception
-