From f84c6deb562dc0ed33a7d24c02975002788e7eaf Mon Sep 17 00:00:00 2001 From: TommyLemon <1184482681@qq.com> Date: Mon, 10 Oct 2022 02:12:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=97=A0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=20NotExistException=20=E4=BC=9A=E5=AF=B9?= =?UTF-8?q?=E5=A4=96=E8=BF=94=E5=9B=9E=E5=BC=82=E5=B8=B8=E8=80=8C=E4=B8=8D?= =?UTF-8?q?=E6=98=AF=E7=A9=BA=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apijson/orm/AbstractObjectParser.java | 37 +++++++++++-------- .../main/java/apijson/orm/AbstractParser.java | 16 +++----- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/APIJSONORM/src/main/java/apijson/orm/AbstractObjectParser.java b/APIJSONORM/src/main/java/apijson/orm/AbstractObjectParser.java index ecfa5b976..0ab8ffad8 100755 --- a/APIJSONORM/src/main/java/apijson/orm/AbstractObjectParser.java +++ b/APIJSONORM/src/main/java/apijson/orm/AbstractObjectParser.java @@ -692,9 +692,11 @@ public AbstractObjectParser setSQLConfig(int count, int page, int position) thro try { sqlConfig = newSQLConfig(false); } - catch (NotExistException e) { - e.printStackTrace(); - return this; + catch (Exception e) { + if (e instanceof NotExistException || (e instanceof CommonException && e.getCause() instanceof NotExistException)) { + return this; + } + throw e; } } sqlConfig.setCount(sqlConfig.getCount() <= 0 ? count : sqlConfig.getCount()).setPage(page).setPosition(position); @@ -722,18 +724,23 @@ public AbstractObjectParser executeSQL() throws Exception { try { sqlReponse = onSQLExecute(); } - catch (NotExistException e) { - // Log.e(TAG, "getObject try { response = getSQLObject(config2); } catch (Exception e) {"); - // if (e instanceof NotExistException) {//非严重异常,有时候只是数据不存在 - // // e.printStackTrace(); - sqlReponse = null;//内部吃掉异常,put到最外层 - // requestObject.put(JSONResponse.KEY_MSG - // , StringUtil.getString(requestObject.get(JSONResponse.KEY_MSG) - // + "; query " + path + " cath NotExistException:" - // + newErrorResult(e).getString(JSONResponse.KEY_MSG))); - // } else { - // throw e; - // } + catch (Exception e) { + if (e instanceof NotExistException || (e instanceof CommonException && e.getCause() instanceof NotExistException)) { + // Log.e(TAG, "getObject try { response = getSQLObject(config2); } catch (Exception e) {"); + // if (e instanceof NotExistException) {//非严重异常,有时候只是数据不存在 + // // e.printStackTrace(); + sqlReponse = null;//内部吃掉异常,put到最外层 + // requestObject.put(JSONResponse.KEY_MSG + // , StringUtil.getString(requestObject.get(JSONResponse.KEY_MSG) + // + "; query " + path + " cath NotExistException:" + // + newErrorResult(e).getString(JSONResponse.KEY_MSG))); + // } else { + // throw e; + // } + } + else { + throw e; + } } } diff --git a/APIJSONORM/src/main/java/apijson/orm/AbstractParser.java b/APIJSONORM/src/main/java/apijson/orm/AbstractParser.java index 722125ad5..58bd20e5f 100755 --- a/APIJSONORM/src/main/java/apijson/orm/AbstractParser.java +++ b/APIJSONORM/src/main/java/apijson/orm/AbstractParser.java @@ -5,8 +5,8 @@ package apijson.orm; -import static apijson.JSONObject.KEY_EXPLAIN; -import static apijson.RequestMethod.GET; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import java.io.UnsupportedEncodingException; import java.lang.management.ManagementFactory; @@ -24,16 +24,12 @@ import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; -import java.util.concurrent.TimeoutException; import javax.activation.UnsupportedDataTypeException; import javax.management.MBeanServer; import javax.management.ObjectName; import javax.management.Query; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - import apijson.JSON; import apijson.JSONRequest; import apijson.JSONResponse; @@ -41,12 +37,10 @@ import apijson.NotNull; import apijson.RequestMethod; import apijson.StringUtil; -import apijson.orm.exception.ConditionErrorException; -import apijson.orm.exception.ConflictException; import apijson.orm.exception.CommonException; -import apijson.orm.exception.NotExistException; -import apijson.orm.exception.NotLoggedInException; -import apijson.orm.exception.OutOfRangeException; + +import static apijson.JSONObject.KEY_EXPLAIN; +import static apijson.RequestMethod.GET; /**parser for parsing request to JSONObject * @author Lemon