larksuite/cli · error · IconParkToolError
{message}
Error message
{message} What it means
fail() is the single error-raising helper of the iconpark_tool script: it always raises IconParkToolError with the supplied message. Every CLI stage (index loading, --limit parsing, icon search, icon resolution, argument parsing) funnels its failure through fail(), so all iconpark_tool errors surface as IconParkToolError with the raw text as the message. It is a controlled failure meant to be caught or printed by the CLI's top-level handler.
Source
Thrown at skills/lark-slides/scripts/iconpark_tool.py:51
"安全": {"iconpark/Safe/protect.svg"},
"防护": {"iconpark/Safe/protect.svg"},
"全球": {"iconpark/Travel/world.svg"},
"市场": {"iconpark/Travel/world.svg"},
"邮件": {"iconpark/Office/envelope-one.svg"},
"联系": {"iconpark/Office/envelope-one.svg"},
"会议": {"iconpark/Office/schedule.svg"},
"日程": {"iconpark/Office/schedule.svg"},
"飞书": {"iconpark/Brand/bydesign.svg"},
}
CURATED_BOOST_SCORE = 40
class IconParkToolError(Exception):
pass
def fail(message: str) -> None:
raise IconParkToolError(message)
def normalize_whitespace(value: str) -> str:
return re.sub(r"\s+", " ", value).strip()
def normalize_token(value: str) -> str:
return normalize_whitespace(value.lower().replace("_", "-"))
def append_unique(target: list[str], token: str) -> None:
normalized = normalize_token(token)
if normalized and normalized not in target:
target.append(normalized)
def tokenize_query(value: str) -> list[str]:
normalized = normalize_token(value)View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Read the exception message for the specific cause and fix the corresponding input (correct icon name, positive integer --limit, valid index path).
- Regenerate or re-download the IconPark index if load_index reported it missing or corrupt, then retry.
- Wrap calls in try/except IconParkToolError when embedding the script as a library, and surface err.args[0] to your user.
- Run with --help (or inspect parse_cli_args) to confirm accepted flags and value ranges before retrying.
Example fix
// before
result = run_cli(["search", "--limit", "0"])
# IconParkToolError: limit must be a positive integer
// after
try:
result = run_cli(["search", "--limit", "10"])
except IconParkToolError as err:
print(f"iconpark: {err}") Defensive patterns
Strategy: try-catch
Validate before calling
if not index_path.exists():
raise SystemExit(f"index file missing: {index_path}; regenerate it first")
limit = args.limit
if not isinstance(limit, int) or limit <= 0:
raise SystemExit("--limit must be a positive integer") Try / catch
try:
run_cli(argv)
except IconParkToolError as err:
print(f"iconpark error: {err}", file=sys.stderr)
sys.exit(2) Prevention
- Validate --limit and icon-name arguments before calling the tool functions.
- Keep the IconPark index regenerated after package upgrades.
- Catch IconParkToolError specifically (it is the script's only failure type) rather than bare Exception.
- Tab-complete or list icons before resolving an id/name.
When it happens
Trigger: Any invalid input or state in the iconpark CLI: load_index on a missing/corrupt index file, parse_limit with a non-positive or non-integer --limit, search_icons with an empty/unknown query, resolve_icon with an unknown icon id, or run_cli catching malformed arguments.
Common situations: Running the icon search script before its IconPark index has been generated/downloaded; typos in icon names; passing --limit 0 or --limit abc; stale index after an IconPark package update.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- --header-scan-rows must be at least 1
- +csv-get truncated the requested range at {source_range}; na
- Pass exactly one of --url or --spreadsheet-token
- Pass only one of --sheet-id or --sheet-name
- lark-cli exited with {completed.returncode}
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/9f5ca16e3169d268.
Report an issue: GitHub.