> ## Documentation Index
> Fetch the complete documentation index at: https://docs.shieldhq.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Error Codes

> Complete list of SHIELD error codes and messages

# Error Codes

Complete reference for SHIELD errors.

## API Errors

### Authentication

| Code       | Message                    | HTTP | Resolution          |
| ---------- | -------------------------- | ---- | ------------------- |
| `AUTH_001` | "No session token"         | 401  | Sign in with wallet |
| `AUTH_002` | "Invalid token"            | 401  | Re-authenticate     |
| `AUTH_003` | "Token expired"            | 401  | Sign in again       |
| `AUTH_004` | "SIWE verification failed" | 401  | Check signature     |
| `AUTH_005` | "Nonce expired"            | 401  | Get new nonce       |

### Policy Errors

| Code      | Message                  | HTTP | Resolution            |
| --------- | ------------------------ | ---- | --------------------- |
| `POL_001` | "Policy not found"       | 404  | Check policyId        |
| `POL_002` | "Policy expired"         | 410  | Request new link      |
| `POL_003` | "Max attempts reached"   | 403  | Link no longer valid  |
| `POL_004` | "Policy revoked"         | 403  | Contact sender        |
| `POL_005` | "Policy already exists"  | 409  | Generate new policyId |
| `POL_006` | "Unauthorized recipient" | 403  | Use correct wallet    |

### Validation

| Code      | Message                    | HTTP | Resolution               |
| --------- | -------------------------- | ---- | ------------------------ |
| `VAL_001` | "Invalid policyId format"  | 400  | Must be 0x + 64 hex      |
| `VAL_002` | "Invalid CID format"       | 400  | Must be Qm... or bafy... |
| `VAL_003` | "Invalid address"          | 400  | Check Ethereum address   |
| `VAL_004` | "Expiry must be future"    | 400  | Set later timestamp      |
| `VAL_005` | "Max attempts must be > 0" | 400  | Set positive number      |

### Rate Limiting

| Code       | Message               | HTTP | Resolution     |
| ---------- | --------------------- | ---- | -------------- |
| `RATE_001` | "Rate limit exceeded" | 429  | Wait and retry |

### Server

| Code      | Message                      | HTTP | Resolution          |
| --------- | ---------------------------- | ---- | ------------------- |
| `SRV_001` | "Internal server error"      | 500  | Contact support     |
| `SRV_002` | "Database connection failed" | 500  | Try again later     |
| `SRV_003` | "IPFS upload failed"         | 502  | Check Pinata status |

## Contract Errors

Reverted with reason string:

| Message                                 | Meaning            | When           |
| --------------------------------------- | ------------------ | -------------- |
| "Policy already exists"                 | policyId taken     | `createPolicy` |
| "Policy does not exist"                 | Invalid policyId   | `logAttempt`   |
| "Policy is not valid"                   | `valid` flag false | `logAttempt`   |
| "Only the recipient can log an attempt" | Wrong caller       | `logAttempt`   |
| "Policy has expired"                    | expiry passed      | `logAttempt`   |
| "Max attempts reached"                  | No attempts left   | `logAttempt`   |

## Wallet Errors

### MetaMask

| Code   | Message               | Solution           |
| ------ | --------------------- | ------------------ |
| 4001   | User rejected         | Approve in wallet  |
| -32603 | Internal error        | Check gas settings |
| -32000 | Gas estimation failed | Increase gas limit |

### WalletConnect

| Code    | Message             | Solution         |
| ------- | ------------------- | ---------------- |
| WC\_001 | Session expired     | Reconnect wallet |
| WC\_002 | Chain not supported | Switch to Base   |

## Decryption Errors

| Error                   | Cause          | Solution                 |
| ----------------------- | -------------- | ------------------------ |
| "Decryption failed"     | Wrong key      | Check URL fragment       |
| "Invalid ciphertext"    | Corrupted data | Re-download from IPFS    |
| "Authentication failed" | Tampered data  | Content may be corrupted |

## Network Errors

| Error             | Cause            | Solution         |
| ----------------- | ---------------- | ---------------- |
| "Failed to fetch" | Network issue    | Check connection |
| "CORS error"      | Misconfiguration | Contact support  |
| "Timeout"         | Slow response    | Retry later      |

## Troubleshooting Flow

```
Error occurred
    │
    ▼
Check HTTP status
    │
    ├── 400 ──▶ Check request format
    │
    ├── 401 ──▶ Re-authenticate
    │
    ├── 403 ──▶ Check permissions
    │
    ├── 404 ──▶ Verify policyId
    │
    ├── 410 ──▶ Link expired, request new
    │
    ├── 429 ──▶ Wait, then retry
    │
    ├── 500 ──▶ Server issue, contact support
    │
    └── Contract ──▶ Check reason string
```

## Contact Support

If error persists:

* Email: [shieldencrypted@gmail.com](mailto:shieldencrypted@gmail.com)
* Include: error code, timestamp, wallet address
