From cc93742422e0978680698289a27e47dd55648e36 Mon Sep 17 00:00:00 2001 From: wangbing Date: Sun, 16 Jun 2019 21:00:54 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81Api=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/modules/Java_api/ApiClient.ftl | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/main/resources/modules/Java_api/ApiClient.ftl b/src/main/resources/modules/Java_api/ApiClient.ftl index e968cdd2..4fbf6f4f 100644 --- a/src/main/resources/modules/Java_api/ApiClient.ftl +++ b/src/main/resources/modules/Java_api/ApiClient.ftl @@ -141,7 +141,13 @@ public class ApiClient { String responseJson = decryptResponse(response, isEnhanced); t = MapperUtil.toJava(responseJson, request.responseClass()); - } catch (Exception e) { + } catch (ConnectException e) { + t = MapperUtil.toJava("{}", request.responseClass()); + t.addError(ErrorType.SYSTEM_ERROR, "网络异常!"); + } catch (SocketTimeoutException e) { + t = MapperUtil.toJava("{}", request.responseClass()); + t.addError(ErrorType.SYSTEM_ERROR, "请求超时!"); + } catch (IOException e) { t = MapperUtil.toJava("{}", request.responseClass()); t.addError(ErrorType.SYSTEM_ERROR, "请求异常!"); } finally { @@ -200,11 +206,11 @@ public class ApiClient { e.printStackTrace(); T t = MapperUtil.toJava("{}", request.responseClass()); if (e instanceof ConnectException) { - t.addError(ErrorType.BUSINESS_ERROR, "网络连接错误!"); + t.addError(ErrorType.BUSINESS_ERROR, "网络异常!"); } else if (e instanceof SocketTimeoutException) { - t.addError(ErrorType.BUSINESS_ERROR, "连接超时!"); + t.addError(ErrorType.BUSINESS_ERROR, "请求超时!"); } else { - t.addError(ErrorType.BUSINESS_ERROR, "请求错误!"); + t.addError(ErrorType.BUSINESS_ERROR, "请求异常!"); } if (after != null) { @@ -225,7 +231,7 @@ public class ApiClient { } catch (Exception e) { e.printStackTrace(); t = MapperUtil.toJava("{}", request.responseClass()); - t.addError(ErrorType.BUSINESS_ERROR, "服务器异常!"); + t.addError(ErrorType.BUSINESS_ERROR, "服务器走了下神!"); } if (after != null) { after.call(request, t); @@ -297,11 +303,11 @@ public class ApiClient { e.printStackTrace(); FileUploadResponse t = MapperUtil.toJava("{}", FileUploadResponse.class); if (e instanceof ConnectException) { - t.addError(ErrorType.BUSINESS_ERROR, "网络连接错误!"); + t.addError(ErrorType.BUSINESS_ERROR, "网络异常!"); } else if (e instanceof SocketTimeoutException) { - t.addError(ErrorType.BUSINESS_ERROR, "连接超时!"); + t.addError(ErrorType.BUSINESS_ERROR, "请求超时!"); } else { - t.addError(ErrorType.BUSINESS_ERROR, "请求错误!"); + t.addError(ErrorType.BUSINESS_ERROR, "请求异常!"); } if (after != null) { @@ -323,7 +329,7 @@ public class ApiClient { } catch (Exception e) { e.printStackTrace(); t = new FileUploadResponse(); - t.addError(ErrorType.BUSINESS_ERROR, "服务器异常!"); + t.addError(ErrorType.BUSINESS_ERROR, "服务器走了下神!"); } if (after != null) {