{"record":{"id":"597adb7e6f7a89a8","repo":"jackwener/OpenCLI","slug":"xiaohongshu-unfollow-failed-err-message-str","errorCode":null,"errorMessage":"xiaohongshu/unfollow failed: ${err?.message ?? String(err)}","messagePattern":"xiaohongshu/unfollow failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/xiaohongshu/unfollow.js","lineNumber":267,"sourceCode":"                'confirm-modal',\n            );\n            if (!confirmResult.ok) {\n                throw new CommandExecutionError(\n                    `xiaohongshu/unfollow: confirmation modal step failed (${confirmResult.kind ?? 'no kind reported'})`,\n                );\n            }\n\n            // Step 3: verify the profile button text flipped back to 关注.\n            const verifyRaw = unwrapEvaluateResult(await page.evaluate(buildVerifyFollowFlippedScript()));\n            if (!verifyRaw || typeof verifyRaw !== 'object' || verifyRaw.ok !== true) {\n                throw new CommandExecutionError(\n                    `xiaohongshu/unfollow: ${verifyRaw?.reason ?? 'state verification failed'}`,\n                );\n            }\n            return [{ status: 'unfollowed', user_id: userId, url }];\n        } catch (err) {\n            if (err instanceof CliError) throw err;\n            throw new CommandExecutionError(\n                `xiaohongshu/unfollow failed: ${err?.message ?? String(err)}`,\n            );\n        }\n    },\n});\n\nexport const __test__ = {\n    assertUserId,\n    buildClickUnfollowScript,\n    buildConfirmModalScript,\n    buildVerifyFollowFlippedScript,\n};\n","sourceCodeStart":249,"sourceCodeEnd":280,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/unfollow.js#L249-L280","documentation":"This is the catch-all wrapper at the end of the unfollow command: any thrown error that is not already a CliError (CommandExecutionError, AuthRequiredError, etc.) is re-wrapped as CommandExecutionError with the 'xiaohongshu/unfollow failed:' prefix. It preserves the original message so the underlying cause (network failure, page timeout, evaluate exception) is visible.","triggerScenarios":"Any non-CliError exception inside the command: page.evaluate threw a script error, page.wait timed out, browser disconnected, or a plain TypeError/undefined access occurred mid-flow.","commonSituations":"Browser crashed or tab closed mid-command; network drop during page.evaluate; a bug in one of the injected scripts threw inside the page context; refactored code threw a raw Error instead of CliError.","solutions":["Read the wrapped err?.message in the output to find the real root cause and fix that first","Retry the command if the cause was transient (network/browser hiccup)","If the inner message points at a script crash, debug buildConfirmModalScript/buildVerifyFollowFlippedScript in the browser console","Ensure custom steps inside the command throw CliError subclasses so they aren't double-wrapped"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await unfollow(userId);\n} catch (err) {\n  // message is 'xiaohongshu/unfollow failed: <root cause>'\n  console.error('unfollow root cause:', err.message.replace('xiaohongshu/unfollow failed: ', ''));\n  if (!isTransient(err)) throw err;\n  await retryWithBackoff(() => unfollow(userId));\n}","preventionTips":["Log err.message (it embeds the original cause) before generic handling","Ensure custom steps throw CliError subclasses to avoid double wrapping","Monitor browser/network health in long automation runs"],"tags":["error-wrapping","browser-automation","xiaohongshu"],"backgroundTag":"generic-command-execution-failure","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}