{"record":{"id":"3869dea6d4b02ac9","repo":"antiwork/gumroad","slug":"something-went-wrong-3869de","errorCode":null,"errorMessage":"Something went wrong.","messagePattern":"Something went wrong\\.","errorType":"exception","errorClass":"ResponseError","httpStatus":null,"severity":"error","filePath":"app/javascript/components/server-components/TaxesCollectionModal.tsx","lineNumber":40,"sourceCode":"};\n\nexport const TaxesCollectionModal = ({ taxesOwed, creditCreationDate, name }: Props) => {\n  const uid = React.useId();\n  const [signature, setSignature] = React.useState(\"\");\n  const [optingIn, setOptingIn] = React.useState(false);\n  const [saving, setSaving] = React.useState(false);\n  const [error, setError] = React.useState(\"\");\n\n  const save = async () => {\n    setSaving(true);\n    try {\n      const response = await request({\n        method: \"POST\",\n        url: Routes.opt_in_to_au_backtax_collection_settings_payments_path(),\n        accept: \"json\",\n        data: { signature },\n      });\n      if (!response.ok) throw new ResponseError();\n      const optInResponse: SaveOptInResponse = typia.assert<SaveOptInResponse>(await response.json());\n      if (optInResponse.success) return window.location.reload();\n      throw new ResponseError(optInResponse.error);\n    } catch (e) {\n      assertResponseError(e);\n      setError(e.message);\n    }\n    setSaving(false);\n  };\n\n  return (\n    <div>\n      <Button color=\"accent\" onClick={() => setOptingIn(true)}>\n        Opt-in to backtaxes collection\n      </Button>\n      {optingIn ? (\n        <Modal\n          open","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/antiwork/gumroad/blob/afeacbd394069a1cbf0c6c50ee8e900925050370/app/javascript/components/server-components/TaxesCollectionModal.tsx#L22-L58","documentation":"Save failure in the Australian back-tax collection opt-in modal. save() POSTs { signature } to opt_in_to_au_backtax_collection_settings_payments_path; a non-2xx throws bare `new ResponseError()`, whose default message from utils/request.ts is 'Something went wrong.'. A 2xx with success:false instead throws ResponseError(optInResponse.error) with the server's own text. assertResponseError in the catch rethrows anything that isn't a ResponseError (e.g. a typia contract violation), so this path is strictly for HTTP-level or refused-opt-in failures.","triggerScenarios":"POST returns 401/419/422/500 (expired session, invalid or missing signature, server-side rejection of the opt-in record) with any body; or success:false with an error string surfaced to the user.","commonSituations":"Signature data not rendered into the modal (server-component props drift), double-submit after the button re-enables, session expiry on a long-open payments page, or backend validation failing while returning no error field.","solutions":["Reload the payments page and reopen the modal so the signature payload is regenerated.","Note that a server-provided message would be shown verbatim — this generic one only appears for non-2xx responses.","Check the POST in devtools: 401/redirect means session; 422 usually means signature mismatch.","Backend: return { error: '...' } on failure paths so users see specifics."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const isOptInRefused = (body: SaveOptInResponse): boolean => body.success === false;","tryCatchPattern":"try {\n  const response = await request({ method: \"POST\", url: Routes.opt_in_to_au_backtax_collection_settings_payments_path(), accept: \"json\", data: { signature } });\n  if (!response.ok) throw new ResponseError();\n  const optInResponse = typia.assert<SaveOptInResponse>(await response.json());\n  if (optInResponse.success) return window.location.reload();\n  throw new ResponseError(optInResponse.error);\n} catch (e) {\n  assertResponseError(e); // rethrow typia/network bugs — only expected failures become UI text\n  setError(e.message);\n}","preventionTips":["Use assertResponseError so contract violations crash loudly instead of becoming toasts.","Return machine-readable errors for opt-in refusals rather than bare non-2xx statuses.","Keep the submit button disabled while saving to prevent double POSTs."],"tags":["taxes","australia","backtax","payments-settings","http","modal"],"backgroundTag":"http-request-failed","analyzedSha":"afeacbd394069a1cbf0c6c50ee8e900925050370","analyzedAt":"2026-08-21T17:58:52.159Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}