arcade-mcp/toolkits/search/arcade_search/exceptions.py
Eric Gustin 6af49ef068
Common changes in all toolkits (#345)
Addresses general improvements to all toolkits including changing ruff
from python 3.9 to python 3.10 which is the reason for the removal of
Optional[] among others.

Also, turns out that our `make install` for toolkits wasn't correctly
checking for whether poetry was installed (&> /dev/null syntax isn't
supported by our check-toolkits GitHub action, so we were installing
poetry twice. I replaced with the more portable >/dev/null 2>&1)

Question: Should we also change ruff to py310 for the `arcade/` package
in a later PR?

-------------------

CU-86b4gzyp6
2025-04-04 09:32:37 -07:00

25 lines
943 B
Python

import json
from arcade.sdk.errors import RetryableToolError
from arcade_search.google_data import COUNTRY_CODES, LANGUAGE_CODES
class GoogleRetryableError(RetryableToolError):
pass
class CountryNotFoundError(GoogleRetryableError):
def __init__(self, country: str | None) -> None:
valid_countries = json.dumps(COUNTRY_CODES, default=str)
message = f"Country not found: '{country}'."
additional_message = f"Valid countries are: {valid_countries}"
super().__init__(message, additional_prompt_content=additional_message)
class LanguageNotFoundError(GoogleRetryableError):
def __init__(self, language: str | None) -> None:
valid_languages = json.dumps(LANGUAGE_CODES, default=str)
message = f"Language not found: '{language}'."
additional_message = f"Valid languages are: {valid_languages}"
super().__init__(message, additional_prompt_content=additional_message)