Skip to content

Commit 0e2b645

Browse files
committed
优化登录报错和远程函数执行报错的提示
1 parent 8df36e2 commit 0e2b645

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

APIJSONORM/src/main/java/apijson/orm/AbstractFunctionParser.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.alibaba.fastjson.JSONArray;
1717
import com.alibaba.fastjson.JSONObject;
1818

19+
import apijson.Log;
1920
import apijson.NotNull;
2021
import apijson.RequestMethod;
2122
import apijson.StringUtil;
@@ -178,15 +179,16 @@ public static Object invoke(@NotNull AbstractFunctionParser parser, @NotNull Str
178179
+ "\n请检查函数名和参数数量是否与已定义的函数一致!"
179180
+ "\n且必须为 function(key0,key1,...) 这种单函数格式!"
180181
+ "\nfunction必须符合Java函数命名,key是用于在request内取值的键!"
181-
+ "\n调用时不要有空格!" + e.getMessage());
182+
+ "\n调用时不要有空格!" + (Log.DEBUG ? e.getMessage() : ""));
182183
}
183184
if (e instanceof InvocationTargetException) {
184185
Throwable te = ((InvocationTargetException) e).getTargetException();
185186
if (StringUtil.isEmpty(te.getMessage(), true) == false) { //到处把函数声明throws Exception改成throws Throwable挺麻烦
186187
throw te instanceof Exception ? (Exception) te : new Exception(te.getMessage());
187188
}
188189
throw new IllegalArgumentException("字符 " + function + " 对应的远程函数传参类型错误!"
189-
+ "\n请检查 key:value 中value的类型是否满足已定义的函数 " + getFunction(fb.getMethod(), fb.getKeys()) + " 的要求!" + e.getMessage());
190+
+ "\n请检查 key:value 中value的类型是否满足已定义的函数 " + getFunction(fb.getMethod(), fb.getKeys()) + " 的要求!"
191+
+ (Log.DEBUG ? e.getMessage() : ""));
190192
}
191193
throw e;
192194
}

APIJSONORM/src/main/java/apijson/orm/AbstractVerifier.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,17 +438,17 @@ public void verifyUseRole(SQLConfig config, String table, RequestMethod method,
438438
public void verifyLogin() throws Exception {
439439
//未登录没有权限操作
440440
if (visitorId == null) {
441-
throw new NotLoggedInException("未登录或登录超时,请登录后再操作!");
441+
throw new NotLoggedInException("未登录或登录过期,请登录后再操作!");
442442
}
443443

444444
if (visitorId instanceof Number) {
445445
if (((Number) visitorId).longValue() <= 0) {
446-
throw new NotLoggedInException("未登录或登录超时,请登录后再操作!");
446+
throw new NotLoggedInException("未登录或登录过期,请登录后再操作!");
447447
}
448448
}
449449
else if (visitorId instanceof String) {
450450
if (StringUtil.isEmpty(visitorId, true)) {
451-
throw new NotLoggedInException("未登录或登录超时,请登录后再操作!");
451+
throw new NotLoggedInException("未登录或登录过期,请登录后再操作!");
452452
}
453453
}
454454
else {

0 commit comments

Comments
 (0)