优化部分代码

This commit is contained in:
Binary Wang
2017-10-20 15:19:19 +08:00
parent afb5e6151f
commit 8d6cfce13c
8 changed files with 29 additions and 39 deletions

View File

@@ -9,8 +9,6 @@ import me.chanjar.weixin.common.util.fs.FileUtils;
import me.chanjar.weixin.common.util.http.MediaDownloadRequestExecutor;
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
@@ -22,8 +20,6 @@ import java.util.UUID;
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
public class WxMaMediaServiceImpl implements WxMaMediaService {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private WxMaService wxMaService;
public WxMaMediaServiceImpl(WxMaService wxMaService) {
@@ -35,8 +31,7 @@ public class WxMaMediaServiceImpl implements WxMaMediaService {
try {
return this.uploadMedia(mediaType, FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType));
} catch (IOException e) {
e.printStackTrace();
throw new WxErrorException(WxError.newBuilder().setErrorMsg(e.getMessage()).build());
throw new WxErrorException(WxError.newBuilder().setErrorMsg(e.getMessage()).build(), e);
}
}
@@ -53,8 +48,7 @@ public class WxMaMediaServiceImpl implements WxMaMediaService {
.create(this.wxMaService.getRequestHttp(), Files.createTempDirectory("wxma").toFile());
return this.wxMaService.execute(executor, MEDIA_GET_URL, "media_id=" + mediaId);
} catch (IOException e) {
this.log.error(e.getMessage(), e);
throw new WxErrorException(WxError.newBuilder().setErrorMsg(e.getMessage()).build());
throw new WxErrorException(WxError.newBuilder().setErrorMsg(e.getMessage()).build(), e);
}
}