File size: 1,337 Bytes
b34e77c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""Test endpoint for verifying error handlers work end-to-end.

This is a development-only endpoint that raises domain errors to verify
the FastAPI exception handlers in app/core/errors.py work correctly.
"""
from __future__ import annotations

from app.core.errors import (
    HoneypotDetectedError,
    InsufficientFundsError,
    PaymentRequiredError,
    WalletNotFoundError,
)
from fastapi import APIRouter

router = APIRouter(prefix="/api/v1/_test_errors", tags=["test-errors"])


@router.get("/wallet_not_found/{address}")
async def test_wallet_not_found(address: str):
    """Raises WalletNotFoundError → 404 with code=wallet_not_found."""
    raise WalletNotFoundError(address, "ethereum")


@router.get("/insufficient_funds")
async def test_insufficient_funds():
    """Raises InsufficientFundsError → 402 with code=insufficient_funds."""
    raise InsufficientFundsError(required=1.5, available=0.3, asset="SOL")


@router.get("/honeypot/{address}")
async def test_honeypot(address: str):
    """Raises HoneypotDetectedError → 422 with code=honeypot_detected."""
    raise HoneypotDetectedError(address, "solana")


@router.get("/payment_required")
async def test_payment_required():
    """Raises PaymentRequiredError → 402 with code=payment_required."""
    raise PaymentRequiredError("scan_token", 0.05, "solana")