Scratchpadに非同期のエラーを処理する機能を追加 (#11850)

* opts.callをtopCallに置換

* AiScriptのエラーコールバックをscratchpadに導入

* lint

* Update CHANGELOG.md
This commit is contained in:
FineArchs
2023-09-19 16:53:43 +09:00
committed by GitHub
parent b0f6c44f36
commit 578b0ebe0c
3 changed files with 28 additions and 17 deletions

View File

@@ -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(),
});
}
}