Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

建议嵌入块中的js支持异步函数,并且错误信息打印到控制台 #13775

Open
wish5115 opened this issue Jan 10, 2025 · 0 comments
Assignees

Comments

@wish5115
Copy link

wish5115 commented Jan 10, 2025

In what scenarios do you need this feature?

如图

image

先说异步函数

参见源代码

image

修改前在new function函数体中只能这样使用

//!js

return (async ()=>{
    const result await query();
    return result;
})();

// 或

const asyncFunc = async () => {
    const result await query();
    return result;
}

return asyncFunc();

修改后可以这样使用

return  await query();

显然后者更简洁和优雅。

再说错误信息

参见源代码

image

思源拦截了错误信息,既无抛出错误也无打印错误信息,只是返回了空数组,界面显示就是没匹配任何内容。

这个非常不友好,如果函数体内有语法错误,应该输出到控制台,这样开发起来更方便。

要想捕获错误,必须自己在代码中try{}catch(e){},如下,非常麻烦,尤其对小白用户,非常不友好。

//!js

try{
    return query("select `aa` as `aa__w80_c:blue_0`, `bb` from ?", [fromTable('20250110154352-pdr5v3t'),item]);
} catch(e) {
    console.error(e)
    return [];
}

Describe the optimal solution

嵌入块中的js支持异步函数,并且错误信息打印到控制台

Describe the candidate solution

No response

Other information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants