{"record":{"id":"64bc8ea9a16180a9","repo":"libnyanpasu/clash-nyanpasu","slug":"result-error","errorCode":null,"errorMessage":"result.error","messagePattern":"result\\.error","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/interface/src/hooks/use-kv-storage.ts","lineNumber":199,"sourceCode":"      }\n    },\n    [key],\n  )\n\n  return [value, setValue, { isLoading }] as const\n}\n\n/**\n * Debug utilities for the backend KV store.\n * Not intended for production use — these bypass per-key subscriptions.\n */\nexport const kvStorageDebug = {\n  /** Returns all stored key-value pairs with values deserialized from JSON. */\n  async getAll(): Promise<Record<string, unknown>> {\n    const result = await commands.getAllStorageItems()\n\n    if (result.status === 'error') {\n      throw new Error(result.error)\n    }\n\n    return Object.fromEntries(\n      result.data.map(({ key, value }) => {\n        try {\n          return [key, JSON.parse(value)]\n        } catch {\n          return [key, value]\n        }\n      }),\n    )\n  },\n\n  /** Removes every entry from the backend storage. */\n  async clear(): Promise<void> {\n    const result = await commands.clearStorage()\n\n    if (result.status === 'error') {","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/frontend/interface/src/hooks/use-kv-storage.ts#L181-L217","documentation":"kvStorageDebug.getAll wraps the Tauri command getAllStorageItems; when the backend replies with status 'error', the raw error string from the IPC result is thrown as a plain Error. It surfaces backend storage-read failures to the frontend caller.","triggerScenarios":"Calling kvStorageDebug.getAll() when the backend getAllStorageItems command returns { status: 'error', error } — e.g. storage file unreadable or backend handler failed.","commonSituations":"Debug tooling reading KV storage while the app data directory is corrupted/locked, or the backend storage service failed to initialize.","solutions":["Inspect the thrown error string to identify the backend storage failure","Check the backend storage file permissions and integrity","Retry after fixing backend state or reinstalling/repairing app data"],"exampleFix":"// before\nconst all = await kvStorageDebug.getAll()\n// after\nlet all\ntry {\n  all = await kvStorageDebug.getAll()\n} catch (e) {\n  console.error('storage read failed:', e)\n  all = {}\n}","handlingStrategy":"try-catch","validationCode":"// No pre-call check possible; backend result is only known after invocation","typeGuard":null,"tryCatchPattern":"try {\n  const all = await kvStorageDebug.getAll()\n} catch (e) {\n  logger.warn('kv getAll failed', e)\n  return {}\n}","preventionTips":["Wrap debug storage reads in try-catch with an empty-object fallback","Check backend storage health before bulk reads"],"tags":["ipc","storage","kv"],"backgroundTag":"api-error-response","analyzedSha":"f7dbce2997c633e484f54788035e770b3ee99773","analyzedAt":"2026-09-08T01:24:59.197Z","contentChangedAt":"2026-09-08T01:24:59.197Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}