Scratchpadに非同期のエラーを処理する機能を追加 (#11850)
* opts.callをtopCallに置換 * AiScriptのエラーコールバックをscratchpadに導入 * lint * Update CHANGELOG.md
This commit is contained in:
@@ -109,6 +109,13 @@ async function run() {
|
||||
print: true,
|
||||
});
|
||||
},
|
||||
err: (err) => {
|
||||
os.alert({
|
||||
type: 'error',
|
||||
title: 'AiScript Error',
|
||||
text: err.toString(),
|
||||
});
|
||||
},
|
||||
log: (type, params) => {
|
||||
switch (type) {
|
||||
case 'end': logs.value.push({
|
||||
@@ -124,20 +131,23 @@ async function run() {
|
||||
let ast;
|
||||
try {
|
||||
ast = parser.parse(code.value);
|
||||
} catch (error) {
|
||||
} catch (err: any) {
|
||||
os.alert({
|
||||
type: 'error',
|
||||
text: 'Syntax error :(',
|
||||
title: 'Syntax Error',
|
||||
text: err.toString(),
|
||||
});
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await aiscript.exec(ast);
|
||||
} catch (err: any) {
|
||||
// AiScript runtime errors should be processed by error callback function
|
||||
// so errors caught here are AiScript's internal errors.
|
||||
os.alert({
|
||||
type: 'error',
|
||||
title: 'AiScript Error',
|
||||
text: err.message,
|
||||
title: 'Internal Error',
|
||||
text: err.toString(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user