Typesense_auth.ErrorTypesense API error handling.
The Typesense API returns errors in a simple format:
{
"message": "Collection not found"
}This module provides utilities for parsing and displaying these errors.
val of_api_error : Openapi.Runtime.api_error -> t optionParse an API error into a structured Typesense error. Returns None if the error body is not valid JSON.
val pp : Format.formatter -> t -> unitPretty-print a Typesense API error.
Format: "Collection not found 404"
val to_string : t -> stringConvert to a human-readable string.
val is_auth_error : t -> boolCheck if this is an authentication/authorization error (401 or 403).
val is_not_found : t -> boolCheck if this is a "not found" error (404).
Exception raised to signal a desired exit code. This is used instead of calling exit directly to avoid issues when running inside Eio's event loop. Catch this exception in the main program outside the Eio context.
Handle an exception, printing a nice error message if it's an API error.
Returns an exit code:
Wrap a function to handle API errors gracefully.
Returns 0 on success, or an appropriate exit code on error.
Wrap a command action to handle API errors gracefully.
Catches API errors, prints a nice message, and raises Exit_code with an appropriate code.