Skip to content

Commit 76f5ee4

Browse files
eternalskyLeoYuan
authored andcommitted
feat: console the expression error
1 parent 37e07bb commit 76f5ee4

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

modules/code-generator/src/generator/ProjectBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ export class ProjectBuilder implements IProjectBuilder {
328328
// template: this.template,
329329
inStrictMode: this.inStrictMode,
330330
tolerateEvalErrors: true,
331-
evalErrorsHandler: '',
331+
evalErrorsHandler: 'console.error(error)',
332332
...this.extraContextData,
333333
...extraContextData,
334334
},

modules/code-generator/src/utils/jsExpression.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@ function getBodyStatements(content: string) {
7979
throw new Error('Can not find Function Statement');
8080
}
8181

82-
export function isJsCode(value: unknown): boolean {
82+
/**
83+
* 是否是广义上的 JSFunction
84+
* @param value
85+
* @returns
86+
*/
87+
export function isBroadJSFunction(value: unknown): boolean {
8388
return isJSExpressionFn(value) || isJSFunction(value);
8489
}
8590

@@ -117,7 +122,7 @@ export function generateFunction(
117122
isBindExpr: false,
118123
},
119124
) {
120-
if (isJsCode(value)) {
125+
if (isBroadJSFunction(value)) {
121126
const functionCfg = value as IPublicTypeJSFunction;
122127
const functionSource = getFunctionSource(functionCfg);
123128
if (config.isMember) {

0 commit comments

Comments
 (0)