Cruel provides a hierarchy of error classes that simulate different failure scenarios. All errors extend from the baseDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/visible/cruel/llms.txt
Use this file to discover all available pages before exploring further.
CruelError class.
CruelError
Base error class for all Cruel-related errors.Error message
Error code for identification
Error name
CruelTimeoutError
Thrown when a timeout chaos event occurs.message:"cruel: injected timeout"code:"CRUEL_TIMEOUT"name:"CruelTimeoutError"
timeout option triggers, simulating operations that never complete.
Example:
CruelNetworkError
Thrown to simulate various network-related failures.Network error type (e.g.,
"packet_loss", "disconnect", "dns_failure", "offline")message:"cruel: network {type}"code:"CRUEL_NETWORK_{TYPE}"name:"CruelNetworkError"
cruel.network.packetLoss()- Simulates packet losscruel.network.disconnect()- Simulates connection dropscruel.network.dns()- Simulates DNS failurescruel.network.offline()- Simulates being offline
CruelHttpError
Thrown to simulate HTTP errors with specific status codes.HTTP status code
message: Custom message or"cruel: http {status}"code:"CRUEL_HTTP"name:"CruelHttpError"
cruel.http.status()- Throws with specific status code(s)cruel.http.serverError()- Throws 500, 502, 503, or 504cruel.http.clientError()- Throws 400, 401, 403, or 404cruel.http.badGateway()- Throws 502cruel.http.serviceUnavailable()- Throws 503cruel.http.gatewayTimeout()- Throws 504
CruelRateLimitError
Thrown to simulate rate limiting scenarios. ExtendsCruelHttpError with status 429.
Suggested retry delay in seconds
status:429message:"cruel: rate limited"name:"CruelRateLimitError"
cruel.http.rateLimit()- Simulates rate limitingcruel.ai.rateLimit()- Simulates AI API rate limiting
CruelAIError
Thrown to simulate AI-specific errors (for AI SDK integration).AI error type (e.g.,
"rate_limit", "overloaded", "context_length", "content_filter", "model_unavailable", "stream_cut")message: Custom message or"cruel: ai {type}"code:"CRUEL_AI_{TYPE}"name:"CruelAIError"
cruel.ai.rateLimit()- AI rate limitingcruel.ai.overloaded()- Model overloadedcruel.ai.contextLength()- Context length exceededcruel.ai.contentFilter()- Content filter triggeredcruel.ai.modelUnavailable()- Model not availablecruel.ai.streamCut()- Stream terminated unexpectedly
CruelAPIError
AI SDK-compatible API error for middleware and model integration.HTTP status code
Whether the error is retryable (defaults to true for 408, 409, 429, 5xx)
Additional error data
cruelModel()- When AI model calls failcruelProvider()- When provider operations failcruelMiddleware()- When middleware intercepts failures
Error Helper Functions
Cruel exports helper functions for creating AI SDK-compatible errors:CruelAPIError with appropriate status codes and messages.