调整Exception类中的消息描述
This commit is contained in:
parent
21e5947ca4
commit
841e1f76f1
@ -344,7 +344,7 @@ public class Pay3Api {
|
||||
writer.newLine();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new WeixinException(e.getMessage());
|
||||
throw new WeixinException(e);
|
||||
} finally {
|
||||
try {
|
||||
if (reader != null) {
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
package com.foxinmy.weixin4j.exception;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.foxinmy.weixin4j.util.StringUtil;
|
||||
|
||||
/**
|
||||
@ -34,8 +32,8 @@ public class WeixinException extends Exception {
|
||||
super(e);
|
||||
}
|
||||
|
||||
public WeixinException(String msg, IOException ex) {
|
||||
super(msg, ex);
|
||||
public WeixinException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public String getErrorCode() {
|
||||
|
||||
@ -20,6 +20,7 @@ import com.foxinmy.weixin4j.http.entity.FormUrlEntity;
|
||||
import com.foxinmy.weixin4j.http.entity.HttpEntity;
|
||||
import com.foxinmy.weixin4j.http.entity.StringEntity;
|
||||
import com.foxinmy.weixin4j.http.factory.HttpClientFactory;
|
||||
import com.foxinmy.weixin4j.http.factory.SimpleHttpClientFactory;
|
||||
import com.foxinmy.weixin4j.model.Consts;
|
||||
import com.foxinmy.weixin4j.util.StringUtil;
|
||||
import com.foxinmy.weixin4j.util.WeixinErrorUtil;
|
||||
@ -44,6 +45,7 @@ public class WeixinRequestExecutor {
|
||||
}
|
||||
|
||||
public WeixinRequestExecutor(HttpParams params) {
|
||||
HttpClientFactory.setDefaultFactory(new SimpleHttpClientFactory());
|
||||
this.httpClient = HttpClientFactory.getInstance();
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
package com.foxinmy.weixin4j.http.weixin;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.KeyStore;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
@ -34,7 +36,7 @@ public class WeixinSSLRequestExecutor extends WeixinRequestExecutor {
|
||||
sslContext.init(kmf.getKeyManagers(), null,
|
||||
new java.security.SecureRandom());
|
||||
} catch (Exception e) {
|
||||
throw new WeixinException(e.getMessage());
|
||||
throw new WeixinException("Key load error", e);
|
||||
}
|
||||
params.setSSLContext(sslContext);
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ public class FileTokenStorager implements TokenStorager {
|
||||
}
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
throw new WeixinException(e.getMessage());
|
||||
throw new WeixinException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ public class FileTokenStorager implements TokenStorager {
|
||||
new FileOutputStream(new File(String.format("%s/%s.xml",
|
||||
cachePath, cacheKey))));
|
||||
} catch (IOException e) {
|
||||
throw new WeixinException(e.getMessage());
|
||||
throw new WeixinException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,7 +272,7 @@ public class MediaApi extends MpApi {
|
||||
file.getAbsolutePath()));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new WeixinException(e.getMessage());
|
||||
throw new WeixinException(e);
|
||||
} finally {
|
||||
try {
|
||||
if (os != null) {
|
||||
@ -346,7 +346,7 @@ public class MediaApi extends MpApi {
|
||||
return new MediaDownloadResult(content,
|
||||
ContentType.create(contentType), fileName);
|
||||
} catch (IOException e) {
|
||||
throw new WeixinException("I/O Error on getBody");
|
||||
throw new WeixinException("I/O Error on getBody", e);
|
||||
} catch (HttpClientException e) {
|
||||
throw new WeixinException(e);
|
||||
}
|
||||
|
||||
@ -238,7 +238,7 @@ public class Pay2Api extends MpApi {
|
||||
} catch (WeixinException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new WeixinException(e.getMessage());
|
||||
throw new WeixinException(e);
|
||||
} finally {
|
||||
if (ca != null) {
|
||||
try {
|
||||
@ -389,7 +389,7 @@ public class Pay2Api extends MpApi {
|
||||
writer.newLine();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new WeixinException(e.getMessage());
|
||||
throw new WeixinException(e);
|
||||
} finally {
|
||||
try {
|
||||
if (reader != null) {
|
||||
|
||||
@ -95,7 +95,7 @@ public class QrApi extends MpApi {
|
||||
os = new FileOutputStream(file);
|
||||
os.write(qrResult.getContent());
|
||||
} catch (IOException e) {
|
||||
throw new WeixinException(e.getMessage());
|
||||
throw new WeixinException(e);
|
||||
} finally {
|
||||
try {
|
||||
if (os != null) {
|
||||
|
||||
@ -6,7 +6,6 @@ import org.junit.Test;
|
||||
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.model.WeixinAccount;
|
||||
import com.foxinmy.weixin4j.mp.api.MenuApi;
|
||||
import com.foxinmy.weixin4j.mp.token.WeixinTokenCreator;
|
||||
import com.foxinmy.weixin4j.token.FileTokenStorager;
|
||||
import com.foxinmy.weixin4j.token.TokenHolder;
|
||||
|
||||
@ -200,7 +200,7 @@ public class MediaApi extends QyApi {
|
||||
file.getAbsolutePath()));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new WeixinException(e.getMessage());
|
||||
throw new WeixinException(e);
|
||||
} finally {
|
||||
try {
|
||||
if (os != null) {
|
||||
@ -272,7 +272,7 @@ public class MediaApi extends QyApi {
|
||||
return new MediaDownloadResult(content,
|
||||
ContentType.create(contentType), fileName);
|
||||
} catch (IOException e) {
|
||||
throw new WeixinException("I/O Error on getBody");
|
||||
throw new WeixinException("I/O Error on getBody", e);
|
||||
} catch (HttpClientException e) {
|
||||
throw new WeixinException(e);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user