catch error avoid white paper

This commit is contained in:
kangwei 2020-06-22 21:09:45 +08:00
parent c1acc2b26b
commit f51bd34737
2 changed files with 30 additions and 6 deletions

View File

@ -266,8 +266,8 @@ export class Designer {
this.oobxList.forEach((item) => item.compute()); this.oobxList.forEach((item) => item.compute());
} }
createSettingEntry(editor: IEditor, nodes: Node[]) { createSettingEntry(nodes: Node[]) {
return new SettingTopEntry(editor, nodes); return new SettingTopEntry(this.editor, nodes);
} }
/** /**
@ -454,7 +454,15 @@ export class Designer {
return props; return props;
} }
return reducers.reduce((xprops, reducer) => reducer(xprops, node), props); return reducers.reduce((xprops, reducer) => {
try {
return reducer(xprops, node)
} catch (e) {
// todo: add log
console.warn(e);
return xprops;
}
}, props);
} }
addPropsReducer(reducer: PropsReducer, stage: TransformStage) { addPropsReducer(reducer: PropsReducer, stage: TransformStage) {

View File

@ -138,7 +138,13 @@ export class SettingPropEntry implements SettingEntry {
val = this.parent.getPropValue(this.name); val = this.parent.getPropValue(this.name);
} }
const { getValue } = this.extraProps; const { getValue } = this.extraProps;
return getValue ? getValue(this, val) : val; try {
return getValue ? getValue(this, val) : val;
} catch (e) {
// todo: add log
console.warn(e);
return val;
}
} }
/** /**
@ -153,7 +159,12 @@ export class SettingPropEntry implements SettingEntry {
} }
const { setValue } = this.extraProps; const { setValue } = this.extraProps;
if (setValue && !extraOptions.disableMutator) { if (setValue && !extraOptions.disableMutator) {
setValue(this, val); try {
setValue(this, val);
} catch (e) {
// todo: add log
console.warn(e);
}
} }
} }
@ -166,7 +177,12 @@ export class SettingPropEntry implements SettingEntry {
} }
const { setValue } = this.extraProps; const { setValue } = this.extraProps;
if (setValue) { if (setValue) {
setValue(this, undefined); try {
setValue(this, undefined);
} catch (e) {
// todo: add log
console.warn(e);
}
} }
} }