Skip to content

Error Handling

Fizzy MCP uses a structured error system with explicit error types.

ErrorCodeRetryableDescription
FizzyApiErrorAPI_ERROR5xx onlyHTTP API errors
FizzyAuthErrorAUTH_ERRORNoAuthentication failures
FizzyForbiddenErrorFORBIDDEN_ERRORNoPermission denied
FizzyNotFoundErrorNOT_FOUND_ERRORNoResource not found
FizzyValidationErrorVALIDATION_ERRORNoInvalid input
FizzyNetworkErrorNETWORK_ERRORYesNetwork failures
FizzyConfigErrorCONFIG_ERRORNoConfiguration issues
FizzyRateLimitErrorRATE_LIMIT_ERRORYesToo many requests

All errors include:

{
name: string; // Error class name
code: string; // Unique error code
message: string; // Human-readable message
retryable: boolean; // Whether to retry
}

When a tool encounters an error, it returns:

{
"content": [{
"type": "text",
"text": "Error: Card not found\nCode: NOT_FOUND_ERROR"
}],
"isError": true
}
import { FizzyAuthError, FizzyNotFoundError } from '@fizzy-mcp/shared';
const result = await client.cards.getByNumber(42);
if (!result.ok) {
const error = result.error;
if (error instanceof FizzyAuthError) {
// Re-authenticate
console.log('Please run: fizzy-mcp auth');
} else if (error instanceof FizzyNotFoundError) {
// Handle missing resource
console.log('Card not found');
} else if (error.retryable) {
// Retry the request
await retry(() => client.cards.getByNumber(42));
}
}

The client automatically retries on:

  • Network errors
  • 5xx server errors
  • 429 rate limit responses

Configuration:

import { withRetry } from '@fizzy-mcp/client';
const result = await withRetry(
() => client.cards.list(),
{
maxRetries: 5,
baseDelayMs: 1000,
maxDelayMs: 30000,
}
);

If you hit rate limits:

  1. The client waits for Retry-After header
  2. Requests are retried automatically
  3. After max retries, FizzyRateLimitError is thrown