Skip to content

Commit 9b9ac5b

Browse files
committed
APIAuto: 优化执行脚本报错的信息显示
1 parent 66c04e4 commit 9b9ac5b

File tree

1 file changed

+9
-5
lines changed
  • APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/js

1 file changed

+9
-5
lines changed

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/js/main.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7598,7 +7598,7 @@ https://github.com/Tencent/APIJSON/issues
75987598
}
75997599

76007600
var evalScript = isAdminOperation || caseScript_ == null ? function () {}
7601-
: function (isPre, code, method, type, url, req, header, callback, res, err) {
7601+
: function (isPre, script, method, type, url, req, header, callback, res, err) {
76027602
var logger = console.log
76037603
console.log = function(msg) {
76047604
logger(msg)
@@ -7607,6 +7607,8 @@ https://github.com/Tencent/APIJSON/issues
76077607

76087608
App.view = 'output'
76097609
vOutput.value = ''
7610+
7611+
script = StringUtil.get(script)
76107612
var isTest = false;
76117613
var isInject = false;
76127614
var data = res == null ? null : res.data
@@ -7628,7 +7630,7 @@ https://github.com/Tencent/APIJSON/issues
76287630
// })()`
76297631
//
76307632
// eval(s)
7631-
var result = eval(code)
7633+
var result = eval(script)
76327634
console.log = logger
76337635
return result
76347636
}
@@ -7637,7 +7639,7 @@ https://github.com/Tencent/APIJSON/issues
76377639
console.log = logger
76387640

76397641
App.loadingCount --
7640-
e.message = '执行脚本报错:\n' + e.message + '; 脚本:' + code
7642+
e.message = '执行脚本报错:\n' + e.message + '; 脚本:\n' + script
76417643

76427644
// TODO if (isPre) {
76437645
App.view = 'error'
@@ -10254,6 +10256,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1025410256

1025510257
this.view = 'output'
1025610258
vOutput.value = ''
10259+
var script = StringUtil.get(vScript.value)
1025710260

1025810261
try {
1025910262
var isTest = true
@@ -10276,15 +10279,16 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1027610279
App.request(isAdminOperation, method, type, url, req, header, callback)
1027710280
}
1027810281

10279-
eval(vScript.value);
10282+
eval(script);
1028010283
}
1028110284
catch(e) {
1028210285
console.log(e);
1028310286
console.log = logger
10287+
e.message = '执行脚本报错:\n' + e.message + '; 脚本:\n' + script
1028410288

1028510289
this.view = 'error'
1028610290
this.error = {
10287-
msg: '执行脚本报错:\n' + e.message
10291+
msg: e.message
1028810292
}
1028910293
}
1029010294

0 commit comments

Comments
 (0)