Open History to see the last commit
1import { msg } from "gt-react";
2
3import { m, type MessageResolver } from "~/i18n/messages";
4
5import type { ChangeRequestTermKind } from "./changeRequestTerm";
6
7/** Diff failures currently include transport wrappers, so recognize the reason inside them. */
8export function describePullRequestDiffError(
9 error: string,
10 providerName: string,
11 term: ChangeRequestTermKind,
12 resolve: MessageResolver = m,
13) {
14 if (/\brate limit\b|\brate[-_]limited\b|\btoo many requests\b/i.test(error)) {
15 return {
16 title: resolve(msg("{providerName} rate limit reached", { providerName })),
17 description: resolve(
18 msg(
19 "{providerName} is temporarily limiting requests, so this diff couldn't be loaded. Try again after the limit resets, or view the changes on {providerName}.",
20 { providerName },
21 ),
22 ),
23 };
24 }
25
26 return {
27 title: resolve(msg("Couldn't load the changes")),
28 description: resolve(
29 msg(
30 "The environment couldn't load this {term, select, mr {merge request} cr {change request} other {pull request}}'s diff. Try again, or view the changes on {providerName}.",
31 { term, providerName },
32 ),
33 ),
34 };
35}