{"record":{"id":"eeeca2a76512068e","repo":"NanmiCoder/MediaCrawler","slug":"error-msg-code-error-code","errorCode":null,"errorMessage":"{error_msg} (code: {error_code})","messagePattern":"(.+?) \\(code: (.+?)\\)","errorType":"exception","errorClass":"IpGetError","httpStatus":null,"severity":"error","filePath":"proxy/providers/wandou_http_proxy.py","lineNumber":106,"sourceCode":"                        expired_time_ts=utils.get_unix_time_from_time_str(\n                            ip_item.get(\"expire_time\")\n                        ),\n                    )\n                    ip_key = f\"WANDOUHTTP_{ip_info_model.ip}_{ip_info_model.port}\"\n                    ip_value = ip_info_model.model_dump_json()\n                    ip_infos.append(ip_info_model)\n                    self.ip_cache.set_ip(\n                        ip_key, ip_value, ex=ip_info_model.expired_time_ts - current_ts\n                    )\n            else:\n                error_msg = res_dict.get(\"msg\", \"unknown error\")\n                # Handle specific error codes\n                error_code = res_dict.get(\"code\")\n                if error_code == 10001:\n                    error_msg = \"General error, check msg content for specific error information\"\n                elif error_code == 10048:\n                    error_msg = \"No available package\"\n                raise IpGetError(f\"{error_msg} (code: {error_code})\")\n        return ip_cache_list + ip_infos\n\n\ndef new_wandou_http_proxy() -> WanDouHttpProxy:\n    \"\"\"\n    Construct WanDou HTTP instance\n    Supports two environment variable naming formats:\n    1. Uppercase format: WANDOU_APP_KEY\n    2. Lowercase format: wandou_app_key\n    Prioritize uppercase format, use lowercase format if not exists\n    Returns:\n\n    \"\"\"\n    # Support both uppercase and lowercase environment variable formats, prioritize uppercase\n    app_key = os.getenv(\"WANDOU_APP_KEY\") or os.getenv(\"wandou_app_key\", \"your_wandou_http_app_key\")\n\n    return WanDouHttpProxy(app_key=app_key)\n","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/NanmiCoder/MediaCrawler/blob/d6f7c5bb906b6dac40ddf343ef9e26438a3de092/proxy/providers/wandou_http_proxy.py#L88-L124","documentation":"Raised by WanDouHttpProxy.get_proxies() when the Wandou (豌豆代理) API response JSON has a non-success code. The message embeds the provider's msg and code, with friendly overrides for 10001 (general error) and 10048 (no available package). This is Wandou's application-level error: HTTP succeeded but the account/order state is wrong.","triggerScenarios":"Calling get_proxies() with an invalid/expired WANDOU_APP_KEY, an account whose proxy package is exhausted or expired (10048), wrong ApiKey vs AppKey mix-up, or requesting more concurrent IPs than the package allows.","commonSituations":"Free trial package used up; WANDOU_APP_KEY env var typo'd or set to the wrong key type; package expired at midnight; running more crawler workers than the package's concurrency limit.","solutions":["For code 10048: log in to the Wandou console and purchase/renew an extraction package","Verify the WANDOU_APP_KEY environment variable matches the key shown in the Wandou console (uppercase WANDOU_APP_KEY takes priority over lowercase wandou_app_key)","For 10001: read the embedded msg — usually invalid key or param — and correct the credential","Reduce concurrent get_proxies() callers to stay within the package's concurrency allowance","Catch IpGetError and retry after a short delay once the package window resets"],"exampleFix":"// before\nraise IpGetError(f\"{error_msg} (code: {error_code})\")\n\n// after — caller side\ntry:\n    proxies = await wandou.get_proxies(num=n)\nexcept IpGetError as e:\n    if \"code: 10048\" in str(e):\n        utils.logger.warning(\"wandou package unavailable, falling back to cached ips\")\n        proxies = await pool.serve_from_cache()\n    else:\n        raise","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    infos = await wandou.get_proxies(num=n)\nexcept IpGetError as e:\n    if \"(code: 10048)\" in str(e):\n        utils.logger.warning(\"wandou package exhausted; continuing with cache\")\n        infos = []\n    elif \"(code: 10001)\" in str(e):\n        raise RuntimeError(f\"wandou credentials invalid: {e}\") from e\n    else:\n        raise","preventionTips":["Verify WANDOU_APP_KEY against the console before long crawls","Track package usage; renew before the 10048 window hits","Distinguish recoverable (quota) from fatal (auth) codes in your handler"],"tags":["proxy","wandou","api-contract","auth","quota"],"backgroundTag":null,"analyzedSha":"d6f7c5bb906b6dac40ddf343ef9e26438a3de092","analyzedAt":"2026-08-15T01:39:07.505Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}