Errors¶
Error types for YNAB API errors and validation failures. Error messages differentiate between user errors (4xx) and server errors (5xx), with retry hints for transient failures like rate limits (429) and server issues.
errors
¶
YNAB API error types and structured error formatting.
Provides a custom exception for YNAB API errors and a formatting function that produces user-friendly messages suitable for MCP ToolError responses. Error messages differentiate between user errors (4xx -- guide correction) and server errors (5xx -- clarify not user's fault), with retry hints for transient failures (429, 5xx).
YNABAPIError
¶
Bases: Exception
Raised when the YNAB API returns an error response.
Attributes:
-
status_code–HTTP status code from the YNAB API.
-
error_id–YNAB-specific error identifier (e.g., "404.2").
-
name–YNAB error name (e.g., "resource_not_found").
-
detail–Human-readable error description from YNAB.
Initialize a YNABAPIError.
Parameters:
-
status_code(int) –HTTP status code from the YNAB API.
-
error_id(str) –YNAB-specific error identifier.
-
name(str) –YNAB error name.
-
detail(str) –Human-readable error description.
Source code in src/ynaa_mcp/errors.py
format_error
¶
format_error(error: YNABAPIError) -> str
Format a YNAB API error into a user-friendly message string.
The returned string is suitable for passing to FastMCP's ToolError constructor. Messages include the original YNAB error name in parentheses for debugging.
Parameters:
-
error(YNABAPIError) –The YNAB API error to format.
Returns:
-
str–A formatted error message string.