fix: add graceful error handling for get_budgets API errors
All checks were successful
Build and Push Monarch MCP Docker Image / build (push) Successful in 16s
All checks were successful
Build and Push Monarch MCP Docker Image / build (push) Successful in 16s
Returns informative error message when Monarch Money API fails, which may occur if budgets are not configured in the account.
This commit is contained in:
@@ -110,7 +110,21 @@ async def get_transactions(
|
||||
async def get_budgets(reason: Optional[str] = None) -> str:
|
||||
"""Get current budget information."""
|
||||
client = await get_authenticated_client()
|
||||
budgets = await client.get_budgets()
|
||||
|
||||
try:
|
||||
budgets = await client.get_budgets()
|
||||
except Exception as e:
|
||||
error_msg = str(e)
|
||||
# Check if this is a Monarch API error about budgets not being set up
|
||||
if "Something went wrong" in error_msg:
|
||||
return serialize_json(
|
||||
{
|
||||
"error": "Budget data unavailable",
|
||||
"detail": "The Monarch Money API returned an error. This may occur if budgets are not configured in your account.",
|
||||
"raw_error": error_msg,
|
||||
}
|
||||
)
|
||||
raise
|
||||
|
||||
# Build a category lookup from categoryGroups
|
||||
category_lookup = {}
|
||||
|
||||
Reference in New Issue
Block a user