jackwener/OpenCLI · error
回复失败: ${errorMessage}
Error message
回复失败: ${errorMessage} What it means
This is the outer catch-all wrapper in the hupu reply CLI: any error thrown during the reply flow that is not a CliError (network failure, API business error like '接口错误 code=...', JSON parse error) is re-thrown as Error('回复失败: <message>'). It guarantees a uniform Chinese-prefixed failure message but chains the original cause text.
Source
Thrown at clis/hupu/reply.js:69
body.quoteId = quote_id;
}
try {
const result = await postHupuJson(page, tid, url, body, 'Reply to Hupu thread', 'reply');
if (result.code === 1) {
return [{
status: '✅ 回复成功',
message: result.msg || result.message || ''
}];
}
else {
throw new Error(`接口错误 code=${result.code}: ${result.msg || result.message}`);
}
}
catch (error) {
if (error instanceof CliError)
throw error;
const errorMessage = error instanceof Error ? error.message : String(error);
throw new Error(`回复失败: ${errorMessage}`);
}
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Look at the text after '回复失败: ' — it contains the underlying cause (接口错误 code=... or network error).
- If it's '接口错误', follow the code/msg fixes (valid tid/topic_id, login, content policy).
- If it's a network/page error, ensure the browser session is alive and retry.
- Re-login to bbs.hupu.com if the cause suggests invalid authentication.
Example fix
// before
try { await reply(...) } catch (e) { /* opaque: 回复失败: ... */ }
// after: inspect the chained cause in your caller
try {
await runReply(tid, topicId, text);
} catch (e) {
const cause = String(e.message).replace('回复失败: ', '');
if (cause.includes('接口错误 code=')) console.error('Hupu rejected reply:', cause);
else throw e; // retryable/network issue
} Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-validate all required args so the call never reaches the API malformed
const args = { tid: '631234567', topic_id: '502', text: 'good game' };
if (!/^\d{9}$/.test(args.tid) || !args.topic_id || !args.text.trim()) {
throw new Error('hupu reply requires 9-digit tid, matching topic_id, and non-empty text');
} Type guard
function isCliError(e) {
return e instanceof Error && e.name === 'CliError';
} Try / catch
try {
const out = await run('hupu reply', { _: [tid, text], topic_id });
} catch (e) {
if (isCliError(e)) throw e; // structured library error, surface as-is
const cause = String(e.message).startsWith('回复失败: ') ? e.message.slice('回复失败: '.length) : e.message;
console.error('Reply failed, root cause:', cause); // then branch on 接口错误 vs network
} Prevention
- Always strip the '回复失败: ' prefix to read the real root cause.
- Validate tid/topic_id/text before invoking to eliminate the most common failure paths.
- Keep the browser session alive and logged in during write operations.
- Distinguish CliError from wrapped Error so you don't double-wrap or lose the original cause.
When it happens
Trigger: Any failure inside the try block of hupu reply: postHupuJson network/HTTP failure, non-1 API code thrown at line 62, or unexpected exceptions during page automation — all get prefixed with '回复失败: '.
Common situations: Hupu API rejecting the reply (see inner error); browser page closed or navigated mid-request; network outage; invalid cookies causing server rejection; unexpected HTML/error page instead of JSON.
Related errors
- 点赞失败: ${errorMessage}
- 接口错误 code=${result.code}: ${result.msg || result.message}
- 接口错误 code=${result.code}: ${result.msg || result.message}
- ${label} failed: ${error?.message ?? error}
- Failed to extract AIbase daily news: ${getErrorMessage(error
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a6c9f46bf58f613a.
Report an issue: GitHub.