/**
* Checks the response.
*
* @param response The response to check.
* @throws Exception If the response has problems (status code not between 200 and 300).
*/
public void checkResponse(HttpResponse<JsonNode> response) throws Exception {
String message = "";
if (response.getBody() != null && !response.getBody().isArray() &&
response.getBody().getObject().has("message")) {
message = " " + response.getBody().getObject().getString("message");
}
if (response.getStatus() == 403) {
throw new PermissionsException("Missing permissions!" + message);
}
if (response.getStatus() == 429) {
// Handled in #checkRateLimit
return;
}
if (response.getStatus() < 200 || response.getStatus() > 299) {
throw new BadResponseException("Received http status code " + response.getStatus() + " with message "
+ response.getStatusText() + " and body " + response.getBody(), response.getStatus(),
response.getStatusText(), response);
}
}
ImplDiscordAPI.java 文件源码
java
阅读 17
收藏 0
点赞 0
评论 0
项目:Javacord
作者:
评论列表
文章目录