diff --git a/src/app/api/api-request.creator.ts b/src/app/api/api-request.creator.ts index e5a1f1f..3faa833 100644 --- a/src/app/api/api-request.creator.ts +++ b/src/app/api/api-request.creator.ts @@ -46,6 +46,11 @@ export class ApiRequestCreator { return of(undefined); } + if (data?.error === undefined && err.status == 429) { + this.bannerService.pushError("Rate Limited", "You have been rate-limited. Please try again later, and please try not to spam stuff again.") + return of(undefined); + } + this.bannerService.pushError(`API Error: ${data?.error?.name} (${err.status})`, data?.error?.message ?? "Unknown error") return of(undefined); } diff --git a/src/app/api/auth.service.ts b/src/app/api/auth.service.ts index 63f29f7..84068d7 100644 --- a/src/app/api/auth.service.ts +++ b/src/app/api/auth.service.ts @@ -110,6 +110,8 @@ export class AuthService { return; } + // TODO hacky, find better solution. Should also reflect the time given in the response header, but Refresh currently only returns that on the first block... + if (err.statusCode === 429) err.message = "You have been rate-limited. Please try again in a few minutes, and please stop spamming this button."; this.bannerService.pushError('Failed to sign in', err.message ?? "No error was provided by the server. Check the console for more details.") console.error(err); } @@ -152,6 +154,8 @@ export class AuthService { return; } + // TODO hacky, find better solution. Should also reflect the time given in the response header, but Refresh currently only returns that on the first block... + if (err.statusCode === 429) err.message = "You have been rate-limited. Please try again in an hour or less, and please stop spamming this button."; this.bannerService.pushError('Failed to register', err.message ?? "No error was provided by the server. Check the console for more details.") console.error(err); }