src/pocketflow/errors

Error types for PocketFlow

Provides a hierarchy of exception types for better error handling and more informative error messages.

Types

CacheError = object of PocketFlowError
  cacheKey*: string
Error in caching layer
FlowExecutionError = object of PocketFlowError
  flowName*: string
  nodeStack*: seq[string]
Error during flow execution
LLMError = object of PocketFlowError
  provider*: string
  statusCode*: int
  responseBody*: string
Error from LLM provider
NodeExecutionError = object of PocketFlowError
  nodeName*: string
  attemptNumber*: int
Error during node execution
PocketFlowError = object of CatchableError
Base exception for all PocketFlow errors
RateLimitError = object of LLMError
  retryAfterSeconds*: int
Rate limit exceeded error
TimeoutError = object of PocketFlowError
  timeoutMs*: int
Operation timeout error
ValidationError = object of PocketFlowError
  fieldName*: string
  invalidValue*: string
Input validation error

Procs

proc newCacheError(msg: string; cacheKey: string = ""): ref CacheError {.
    ...raises: [], tags: [], forbids: [].}
Creates a new CacheError
proc newLLMError(msg: string; provider: string = ""; statusCode: int = 0;
                 responseBody: string = ""): ref LLMError {....raises: [],
    tags: [], forbids: [].}
Creates a new LLMError
proc newNodeExecutionError(msg: string; nodeName: string = "";
                           attemptNumber: int = 0): ref NodeExecutionError {.
    ...raises: [], tags: [], forbids: [].}
Creates a new NodeExecutionError
proc newPersistenceError(msg: string): ref PocketFlowError {....raises: [],
    tags: [], forbids: [].}
Creates a new Persistence-related error
proc newPocketFlowError(msg: string): ref PocketFlowError {....raises: [],
    tags: [], forbids: [].}
Creates a new PocketFlowError
proc newRAGError(msg: string): ref PocketFlowError {....raises: [], tags: [],
    forbids: [].}
Creates a new RAG-related error
proc newRateLimitError(msg: string; provider: string = "";
                       retryAfterSeconds: int = 60): ref RateLimitError {.
    ...raises: [], tags: [], forbids: [].}
Creates a new RateLimitError
proc newTimeoutError(msg: string; timeoutMs: int): ref TimeoutError {.
    ...raises: [], tags: [], forbids: [].}
Creates a new TimeoutError