likkisai59/spond/error-handling-fallback

Claude Code and agent skill by likkisai59/spond

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Error handling and fallback mechanisms for FastAPI with custom exceptions, global handlers, and graceful degradation

Install

npx vskill@latest install likkisai59/spond/error-handling-fallback

SKILL.md

The same SKILL.md was published earlier as likkisai59/spond/error-handling-fallback.

Error Handling and Fallback Skill

Custom Exception Hierarchy

python
class PaymentServiceError(Exception):
def __init__(self, code: str, message: str, status_code: int = 500):
self.code = code
self.message = message
self.status_code = status_code
class OrderNotFoundError(PaymentServiceError):
def __init__(self, order_id: str):
super().__init__("ORDER_NOT_FOUND", f"Order {order_id} not found", 404)
class RazorpayAPIError(PaymentServiceError):
def __init__(self, detail: str):
super().__init__("RAZORPAY_API_ERROR", detail, 502)

Global Exception Handler

python
from fastapi import Request
from fastapi.responses import JSONResponse
@app.exception_handler(PaymentServiceError)
async def payment_error_handler(request: Request, exc: PaymentServiceError):
return JSONResponse(
status_code=exc.status_code,
content={
"error": {
"code": exc.code,
"message": exc.message,
"request_id": getattr(request.state, "request_id", None)
}
}
)

Fallback Patterns

python
async def call_razorpay_with_fallback(payload: dict, max_retries: int = 2):
for attempt in range(max_retries):
try:
return await razorpay_client.post("/payment_links", json=payload)
except httpx.TimeoutException:
if attempt == max_retries - 1:
raise RazorpayAPIError("Service unavailable")
await asyncio.sleep(2 ** attempt)

Status Codes

  • 400: Bad Request, 401: Unauthorized, 403: Forbidden, 404: Not Found
  • 409: Conflict, 422: Validation Error, 500: Internal Error
  • 502: Bad Gateway (external API), 503: Service Unavailable

Best Practices

  1. Use custom exception hierarchy
  2. Include request_id in error responses
  3. Implement retry with exponential backoff
  4. Log errors with full context
  5. Never expose internal details in production errors

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/likkisai59/spond/error-handling-fallback/badge)](https://verified-skill.com/skills/likkisai59/spond/error-handling-fallback)

Something wrong with this skill or its page? Tell us.