[Fix #11] 修复在图片缓存失效的情况下, 'getImageToBotCode'依然会尝试从缓存获取图片File对象导致NPE;

[Change] BotCommandProcess 调整字符串拼接形式, 统一错误提示语的格式;
This commit is contained in:
2020-06-04 09:29:53 +08:00
parent eb2de09859
commit 69da2b02ac
4 changed files with 125 additions and 57 deletions

View File

@ -1,6 +1,7 @@
package net.lamgc.cgj.bot.cache;
import net.lamgc.cgj.Main;
import net.lamgc.cgj.bot.cache.exception.HttpRequestException;
import net.lamgc.cgj.pixiv.PixivURL;
import net.lamgc.cgj.util.URLs;
import net.lamgc.utils.event.EventHandler;
@ -60,8 +61,9 @@ public class ImageCacheHandler implements EventHandler {
throw e;
}
if(response.getStatusLine().getStatusCode() != 200) {
log.warn("Http请求异常{}", response.getStatusLine());
throw new IOException("Http Response Error: " + response.getStatusLine());
HttpRequestException requestException = new HttpRequestException(response);
log.warn("Http请求异常{}", requestException.getStatusLine());
throw requestException;
}
log.debug("正在下载...(Content-Length: {}KB)", response.getEntity().getContentLength() / 1024);