{"record":{"id":"635ee9cf8554c71f","repo":"jackwener/OpenCLI","slug":"pixiv-bookmark-archive-failed-error-message","errorCode":null,"errorMessage":"Pixiv bookmark archive failed: ${error?.message || error}","messagePattern":"Pixiv bookmark archive failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/pixiv/bookmark-download.js","lineNumber":226,"sourceCode":"        const destination = plan.kind === 'novel'\n          ? commitNovelFile(plan)\n          : await commitIllustPlan(plan, cookies);\n        committed.push(plan);\n        const id = type === 'novel' ? plan.row.novel_id : plan.row.illust_id;\n        results.push({\n          rank: plan.row.rank,\n          type,\n          id,\n          title: plan.row.title,\n          download_status: 'success',\n          path: destination,\n        });\n      }\n      return results;\n    } catch (error) {\n      for (const plan of committed.reverse()) cleanupPlan(plan);\n      if (error instanceof CommandExecutionError) throw error;\n      throw new CommandExecutionError(`Pixiv bookmark archive failed: ${error?.message || error}`);\n    }\n  },\n});\n","sourceCodeStart":208,"sourceCodeEnd":230,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/pixiv/bookmark-download.js#L208-L230","documentation":"The final catch-all for the bookmark archive run: if any error escapes the download/commit loop that is not already a CommandExecutionError, it is wrapped in this generic 'Pixiv bookmark archive failed' message after rolling back all committed plans (cleanupPlan in reverse order). Typed CommandExecutionErrors (like the ones above) pass through unchanged.","triggerScenarios":"Any non-CommandExecutionError thrown inside the committed-results try block — e.g. novel file commits failing with raw fs errors, network fetch of bookmarks failing mid-loop, unexpected null dereferences in the results loop, or a download tool throwing a raw Error.","commonSituations":"Network drop partway through archiving multiple pages; disk filling up mid-archive; a novel download path hitting an unexpected fs error (EACCES/ENOSPC); a library bug throwing a plain Error; process-level interruptions surfacing as generic errors.","solutions":["Read the inner error.message to find the real root cause (fs vs network vs auth)","Re-run the archive after fixing the underlying condition; previously committed files are protected by the overwrite guard","Check disk space and permissions on the output root","Verify the Pixiv session is still valid if later items fail after the first few succeed","Wrap known raw error sources in CommandExecutionError for clearer typed failures"],"exampleFix":"// before\nthrow new CommandExecutionError(`Pixiv bookmark archive failed: ${error?.message || error}`);\n// after: keep the cause for diagnostics\nconst wrapped = new CommandExecutionError(`Pixiv bookmark archive failed: ${error?.message || error}`);\nwrapped.cause = error;\nthrow wrapped;","handlingStrategy":"try-catch","validationCode":"// preflight before the archive loop\nif (!fs.existsSync(outputRoot) || fs.statSync(outputRoot).code === undefined) {\n  fs.mkdirSync(outputRoot, { recursive: true });\n}\nif (fs.statSync(outputRoot).mode & 0o200 === 0) throw new Error('output root not writable');","typeGuard":"function isCommandExecutionError(e) {\n  return e instanceof Error && e.constructor.name === 'CommandExecutionError';\n}","tryCatchPattern":"try {\n  await pixivBookmarkDownload({ page, type, output });\n} catch (err) {\n  if (err instanceof CommandExecutionError && !/archive failed/.test(err.message)) throw err; // typed, specific\n  console.error(`Archive aborted: ${err.message}`);\n  // committed items were rolled back; safe to retry the whole run\n}","preventionTips":["Check disk space and permissions before multi-item archives","Retry the run after fixing the root cause — the overwrite guard makes it idempotent","Keep the Pixiv session alive for the whole run","Surface raw fs/network errors early with typed wrappers"],"tags":["pixiv","bookmarks","wrapper-error","rollback"],"backgroundTag":"batch-archive-failed-wrapped","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}