skip java uuid request/validation if api sends rate limit response
All checks were successful
delpoy / build-and-deploy (push) Successful in 51s
All checks were successful
delpoy / build-and-deploy (push) Successful in 51s
This commit is contained in:
@@ -9,11 +9,16 @@ export class UserNotFoundError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
export class RateLimitError extends Error {}
|
||||
|
||||
export class ApiError extends Error {}
|
||||
|
||||
export async function getJavaUuid(username: string): Promise<string> {
|
||||
const response = await fetch(`https://api.mojang.com/users/profiles/minecraft/${username}`);
|
||||
if (!response.ok) {
|
||||
if (response.status == 429) {
|
||||
throw new RateLimitError();
|
||||
}
|
||||
throw response.status < 500
|
||||
? new UserNotFoundError(username)
|
||||
: new ApiError(`mojang server error (${response.status}): ${await response.text()}`);
|
||||
|
||||
Reference in New Issue
Block a user