{"record":{"id":"caf67939c75358b3","repo":"Foundry376/Mailspring","slug":"usageexceedederror","errorCode":"UsageExceededError","errorMessage":"UsageExceededError","messagePattern":"UsageExceededError","errorType":"error_code","errorClass":"UsageExceededError","httpStatus":400,"severity":"error","filePath":"app/internal_packages/composer-grammar-check/lib/grammar-check-service.ts","lineNumber":135,"sourceCode":"    this._readConfig();\n\n    let data: LanguageToolResponse;\n    try {\n      data = await MailspringAPIRequest.makeRequest({\n        server: 'identity',\n        method: 'POST',\n        path: '/api/grammar/check',\n        json: true,\n        body: {\n          messageId,\n          text,\n          language: language || this.language,\n        },\n      });\n    } catch (err) {\n      // 400 = quota reached (\"Quota Reached\")\n      if (err.statusCode === 400) {\n        throw new UsageExceededError();\n      }\n      // 429 = rate limited — surface as a transient error, caller will retry on next dirty check\n      if (err.statusCode === 429) {\n        throw new Error('Grammar check rate limit reached, please try again shortly.');\n      }\n      // 502 = LanguageTool backend unavailable\n      if (err.statusCode === 502) {\n        throw new Error('Grammar check service is temporarily unavailable.');\n      }\n      throw err;\n    }\n\n    const filtered = data.matches.filter((match) => match.rule.issueType !== 'misspelling');\n\n    return filtered.map((match) => ({\n      offset: match.offset,\n      length: match.length,\n      message: match.message,","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/Foundry376/Mailspring/blob/648c685d602ece6bb00c22534b8734de6ac644b3/app/internal_packages/composer-grammar-check/lib/grammar-check-service.ts#L117-L153","documentation":"Raised by GrammarCheckService.check when the identity backend answers HTTP 400 ('Quota Reached') for POST /api/grammar/check, meaning the account has exhausted its grammar-check quota. It is a sentinel error type the package uses to distinguish quota exhaustion from other failures.","triggerScenarios":"Thrown at app/internal_packages/composer-grammar-check/lib/grammar-check-service.ts:135 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Surface an inline notice in the composer that the free grammar-check quota is used up and offer a link to upgrade or wait for the quota window to reset","Cache the UsageExceededError state so subsequent dirty checks skip the API call until the window resets"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"648c685d602ece6bb00c22534b8734de6ac644b3","analyzedAt":"2026-09-03T02:00:24.311Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}