{"record":{"id":"6595e65bf11a6558","repo":"gildas-lormeau/SingleFile","slug":"response-error-6595e6","errorCode":null,"errorMessage":"response.error","messagePattern":"response\\.error","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/lib/dropbox/dropbox.js","lineNumber":336,"sourceCode":"\t\t\t\t}\n\t\t\t})\n\t\t}\n\t});\n\tif (httpFinishResponse.status == 200) {\n\t\treturn getJSON(httpFinishResponse);\n\t} else if (httpFinishResponse.status == 409 && mediaUploader.filenameConflictAction == CONFLICT_ACTION_PROMPT) {\n\t\tmediaUploader.offset = 0;\n\t\treturn mediaUploader.upload();\n\t} else {\n\t\tthrow new Error(\"unknown_error (\" + httpFinishResponse.status + \")\");\n\t}\n}\n\nasync function getJSON(httpResponse) {\n\thttpResponse = getResponse(httpResponse);\n\tconst response = await httpResponse.json();\n\tif (response.error) {\n\t\tthrow new Error(response.error);\n\t} else {\n\t\treturn response;\n\t}\n}\n\nfunction getResponse(httpResponse) {\n\tif (httpResponse.status == 200) {\n\t\treturn httpResponse;\n\t} else if (httpResponse.status == 401) {\n\t\tthrow new Error(\"invalid_token\");\n\t} else {\n\t\tthrow new Error(\"unknown_error (\" + httpResponse.status + \")\");\n\t}\n}\n\nfunction stringify(value) {\n\treturn JSON.stringify(value).replace(ENCODED_CHARS,\n\t\tfunction (c) {","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/gildas-lormeau/SingleFile/blob/517fb7c5cf2096d89933b747e862d8ecf616a9f9/src/lib/dropbox/dropbox.js#L318-L354","documentation":"getJSON parses a Dropbox API response body and throws Error(response.error) whenever the JSON contains an 'error' field. The thrown message is the raw error value from Dropbox, so its shape depends entirely on what Dropbox returned (often an object or reason string).","triggerScenarios":"Any Dropbox endpoint call (via getJSON) that returns 200 but with an error payload — e.g. rate-limit details, invalid cursor, malformed arguments reported inside a 200/other response.","commonSituations":"Expired or insufficient-scope tokens producing Dropbox error payloads; malformed paths or upload parameters; paginated list calls with invalid/stale cursors.","solutions":["Inspect the thrown error value — it is Dropbox's own error payload — and fix the root cause it describes.","Re-authenticate if the error indicates invalid/expired token.","Validate request parameters (paths, cursors, options) against the Dropbox API docs.","Add retry with backoff for rate-limit (too_many_requests / retry-after) errors."],"exampleFix":"// before\nconst data = await dropbox.getFile(...); // throws raw Dropbox error\n// after\ntry {\n  const data = await dropbox.getFile(...);\n} catch (e) {\n  const reason = typeof e.message === 'string' ? e.message : JSON.stringify(e.message);\n  if (reason.includes('expired_access_token')) await reauthorize();\n  else throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const data = await dropboxCall(...);\n} catch (e) {\n  // e.message is Dropbox's raw error payload\n  const reason = typeof e.message === 'string' ? e.message : JSON.stringify(e.message);\n  if (reason.includes('expired_access_token') || reason.includes('invalid_access_token')) {\n    await reauthorize();\n  } else if (reason.includes('too_many_requests')) {\n    await sleep(backoff); // retry\n  } else throw e;\n}","preventionTips":["Log the full thrown message — it contains Dropbox's error details","Keep tokens fresh and request the required scopes","Validate paths/cursors/params against Dropbox API docs before calling"],"tags":["dropbox","api-error","http"],"backgroundTag":"api-error-payload","analyzedSha":"517fb7c5cf2096d89933b747e862d8ecf616a9f9","analyzedAt":"2026-09-01T10:05:25.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}