{"record":{"id":"6753944a0d0e0ad5","repo":"antiwork/gumroad","slug":"this-affiliation-was-already-removed-refreshing-y","errorCode":null,"errorMessage":"This affiliation was already removed. Refreshing your affiliations.","messagePattern":"This affiliation was already removed\\. Refreshing your affiliations\\.","errorType":"exception","errorClass":"AffiliationAlreadyRemovedError","httpStatus":404,"severity":"error","filePath":"app/javascript/data/affiliated_products.ts","lineNumber":63,"sourceCode":"    super(\"This affiliation was already removed. Refreshing your affiliations.\");\n  }\n}\n\ntype AffiliationRemovedData = PagedAffiliatedProductsData & { stats: AffiliatedPageStats };\n\nexport const removeSelfAsAffiliate = async (\n  affiliateId: string,\n  { query, sort }: { query?: string; sort?: Sort<SortKey> | null } = {},\n): Promise<AffiliationRemovedData> => {\n  const response = await request({\n    method: \"DELETE\",\n    accept: \"json\",\n    url: Routes.products_affiliated_path(affiliateId, { query, sort }),\n  });\n  // A stale row 404s with the HTML error page, so parse only once the response is\n  // known good — a JSON parse failure here would escape the caller's catch and\n  // strand the confirm modal in its in-flight state.\n  if (response.status === 404) throw new AffiliationAlreadyRemovedError();\n  if (!response.ok) {\n    const body = await response.text();\n    let message = \"Sorry, something went wrong. Please try again.\";\n    try {\n      // A role that may view this page but not remove affiliations gets a 401 naming the role —\n      // worth showing rather than replacing with a generic failure.\n      message = typia.assert<{ error: string }>(JSON.parse(body)).error;\n    } catch {\n      /* non-JSON body: keep the generic message */\n    }\n    throw new ResponseError(message);\n  }\n  return typia.assert<AffiliationRemovedData>(await response.json());\n};\n","sourceCodeStart":45,"sourceCodeEnd":78,"githubUrl":"https://github.com/antiwork/gumroad/blob/afeacbd394069a1cbf0c6c50ee8e900925050370/app/javascript/data/affiliated_products.ts#L45-L78","documentation":"Error \"This affiliation was already removed. Refreshing your affiliations.\" thrown in antiwork/gumroad.","triggerScenarios":"Thrown at app/javascript/data/affiliated_products.ts:63 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"afeacbd394069a1cbf0c6c50ee8e900925050370","analyzedAt":"2026-08-21T17:58:52.159Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}