Delete WxaCodeError.
This commit is contained in:
parent
1241072a1b
commit
89a5c79e7a
@ -1,7 +1,6 @@
|
||||
package com.foxinmy.weixin4j.wxa.api;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
@ -144,20 +143,10 @@ public class QrCodeApi extends WxaApi {
|
||||
}
|
||||
|
||||
private byte[] toImageBytes(WeixinResponse response) throws WeixinException {
|
||||
try {
|
||||
return readImageBytes(response);
|
||||
} catch (IOException e) {
|
||||
throw new WeixinException(e);
|
||||
} catch (WxaCodeError e) {
|
||||
throw new WeixinException(Integer.toString(e.getErrcode()), e.getErrmsg());
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] readImageBytes(WeixinResponse response) throws IOException, WxaCodeError {
|
||||
final String contentType = response.getHeaders().getContentType();
|
||||
if (contentType != null && contentType.equals(ContentType.APPLICATION_JSON.getMimeType().getType())) {
|
||||
WxaCodeError wxaCodeError = JSON.parseObject(response.getContent(), WxaCodeError.class);
|
||||
throw wxaCodeError;
|
||||
final WxaApiResult r = response.getAsObject(WxaApiResult.TYPE_REFERENCE);
|
||||
throw r.toWeixinException();
|
||||
} else {
|
||||
return response.getContent();
|
||||
}
|
||||
|
||||
@ -1,39 +0,0 @@
|
||||
package com.foxinmy.weixin4j.wxa.api;
|
||||
|
||||
class WxaCodeError extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 2018052201L;
|
||||
|
||||
private int errcode;
|
||||
private String errmsg;
|
||||
|
||||
public WxaCodeError() {
|
||||
}
|
||||
|
||||
public WxaCodeError(int errcode, String errmsg) {
|
||||
this.errcode = errcode;
|
||||
this.errmsg = errmsg;
|
||||
}
|
||||
|
||||
public int getErrcode() {
|
||||
return errcode;
|
||||
}
|
||||
|
||||
public void setErrcode(int errcode) {
|
||||
this.errcode = errcode;
|
||||
}
|
||||
|
||||
public String getErrmsg() {
|
||||
return errmsg;
|
||||
}
|
||||
|
||||
public void setErrmsg(String errmsg) {
|
||||
this.errmsg = errmsg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return errmsg;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user