{"record":{"id":"92b4c8a46ab48481","repo":"jackwener/OpenCLI","slug":"xiaohongshu-follow-failed-err-message-strin","errorCode":null,"errorMessage":"xiaohongshu/follow failed: ${err?.message ?? String(err)}","messagePattern":"xiaohongshu/follow failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/xiaohongshu/follow.js","lineNumber":210,"sourceCode":"            if (currentProfile?.[1] !== userId) {\n                throw new CommandExecutionError(\n                    `xiaohongshu/follow: expected profile ${userId}, got ${parsedHref.pathname}`,\n                );\n            }\n\n            const result = requireActionResult(\n                await page.evaluate(buildFollowScript()),\n                'follow-action',\n            );\n            if (!result.ok) {\n                throw new CommandExecutionError(\n                    `xiaohongshu/follow failed: ${result.reason ?? 'unknown reason'}`,\n                );\n            }\n            return [{ status: result.state, user_id: userId, url }];\n        } catch (err) {\n            if (err instanceof CliError) throw err;\n            throw new CommandExecutionError(\n                `xiaohongshu/follow failed: ${err?.message ?? String(err)}`,\n            );\n        }\n    },\n});\n\nexport const __test__ = {\n    assertUserId,\n    buildFollowScript,\n};\n","sourceCodeStart":192,"sourceCodeEnd":221,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/follow.js#L192-L221","documentation":"Catch-all wrapper: any non-CliError thrown inside the follow command's try block is rethrown as CommandExecutionError with the prefix 'xiaohongshu/follow failed:' plus the original message. It preserves the underlying cause's message while normalizing the error type for the CLI. CliError instances pass through untouched.","triggerScenarios":"Any unexpected exception during the follow flow that is not a CliError — e.g. page.evaluate threw (page closed/navigated away), requireActionResult detected a malformed payload indirectly? no (that throws CommandExecutionError directly, which is a CliError and passes through) — realistically evaluate failures, timeouts, or browser disconnection.","commonSituations":"Chrome tab closed mid-run; navigation interrupted; evaluate returned an unserializable value; random wait interrupted by page crash.","solutions":["Inspect the embedded err.message after the prefix to find the root cause.","Reopen Chrome and ensure the target tab/page object is alive before rerunning.","Retry the command; transient browser/navigation issues are the usual cause.","If it persists, run with verbose logging to capture the original stack."],"exampleFix":"// before\n// page closed before evaluate\nawait follow(userId);\n// after\nconst page = await ensureBrowserPage(); // keep page alive\nawait page.goto(profileUrl);\nawait follow(userId);","handlingStrategy":"try-catch","validationCode":"// Ensure the browser/page is alive before the command\nif (page.isClosed?.()) throw new Error('target page closed before follow');","typeGuard":"function isWrappedFollowError(err) {\n  return err instanceof Error && err.message.startsWith('xiaohongshu/follow failed:');\n}","tryCatchPattern":"try {\n  await follow(userId);\n} catch (err) {\n  if (isWrappedFollowError(err)) {\n    const cause = err.message.replace('xiaohongshu/follow failed: ', '');\n    console.error('underlying cause:', cause);\n  } else throw err;\n}","preventionTips":["Keep the Chrome tab open for the duration of the command.","Avoid navigating the page manually while the CLI is running.","Read the message after the prefix to identify the root cause before retrying.","Run with verbose output to capture original stacks."],"tags":["xiaohongshu","error-wrapping","browser-automation"],"backgroundTag":"unhandled-exception-wrapped","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}