Error Handling
PolicyBlockError
Section titled “PolicyBlockError”Raised when the pipeline blocks a request:
from tappass import Agent, PolicyBlockError
agent = Agent("http://localhost:9620", "tp_...")
try: response = agent.chat("Show me all credit card numbers")except PolicyBlockError as e: print(e.blocked_by) # "detect_pii" print(e.classification) # "RESTRICTED" print(e.reason) # "PII detected in request" print(e.step_details) # full step outputFields
Section titled “Fields”| Field | Type | Description |
|---|---|---|
blocked_by | str | Pipeline step that blocked |
classification | str | Data classification at time of block |
reason | str | Human-readable reason |
step_details | dict | Full step output (detections, scores) |
Retries
Section titled “Retries”The SDK retries on transient errors (network timeouts, 502/503/504):
agent = Agent( "http://localhost:9620", "tp_...", timeout=30, # per-request timeout max_retries=2, # retry count (default: 2))PolicyBlockError is never retried: it’s a deliberate policy decision, not a transient failure.
Connection errors
Section titled “Connection errors”from tappass.errors import TapPassConnectionError
try: response = agent.chat("Hello")except TapPassConnectionError: print("TapPass server is unreachable")