🎨 优化部分代码,明确出错信息

This commit is contained in:
Binary Wang
2020-10-19 00:24:17 +08:00
parent 07bc5a5eac
commit 151004110f

View File

@ -58,7 +58,7 @@ public class HttpResponseProxy {
private String getFileName(CloseableHttpResponse response) throws WxErrorException { private String getFileName(CloseableHttpResponse response) throws WxErrorException {
Header[] contentDispositionHeader = response.getHeaders("Content-disposition"); Header[] contentDispositionHeader = response.getHeaders("Content-disposition");
if (contentDispositionHeader == null || contentDispositionHeader.length == 0) { if (contentDispositionHeader == null || contentDispositionHeader.length == 0) {
throw new WxErrorException("无法获取到文件名"); throw new WxErrorException("无法获取到文件名Content-disposition为空");
} }
return this.extractFileNameFromContentString(contentDispositionHeader[0].getValue()); return this.extractFileNameFromContentString(contentDispositionHeader[0].getValue());
@ -76,7 +76,7 @@ public class HttpResponseProxy {
private String extractFileNameFromContentString(String content) throws WxErrorException { private String extractFileNameFromContentString(String content) throws WxErrorException {
if (content == null || content.length() == 0) { if (content == null || content.length() == 0) {
throw new WxErrorException("无法获取到文件名"); throw new WxErrorException("无法获取到文件名content为空");
} }
Matcher m = PATTERN.matcher(content); Matcher m = PATTERN.matcher(content);
@ -84,7 +84,7 @@ public class HttpResponseProxy {
return m.group(1); return m.group(1);
} }
throw new WxErrorException("无法获取到文件名"); throw new WxErrorException("无法获取到文件名header信息有问题");
} }
} }