mirror of
https://github.com/elyby/chrly.git
synced 2025-05-31 14:11:51 +05:30
Handle 403 Forbidden error from Mojang's API
This commit is contained in:
@@ -125,6 +125,8 @@ func validateResponse(response *http.Response) error {
|
||||
_ = json.Unmarshal(body, &decodedError)
|
||||
|
||||
return &BadRequestError{ErrorType: decodedError.Error, Message: decodedError.Message}
|
||||
case response.StatusCode == 403:
|
||||
return &ForbiddenError{}
|
||||
case response.StatusCode == 429:
|
||||
return &TooManyRequestsError{}
|
||||
case response.StatusCode >= 500:
|
||||
@@ -166,6 +168,15 @@ func (*BadRequestError) IsMojangError() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// When Mojang decides you're such a bad guy, this error appears (even if the request has no authorization)
|
||||
type ForbiddenError struct {
|
||||
ResponseError
|
||||
}
|
||||
|
||||
func (*ForbiddenError) Error() string {
|
||||
return "Forbidden"
|
||||
}
|
||||
|
||||
// When you exceed the set limit of requests, this error will be returned
|
||||
type TooManyRequestsError struct {
|
||||
ResponseError
|
||||
|
||||
Reference in New Issue
Block a user