Improve cylical dependency error (#3471)
This commit is contained in:
parent
08ebbe410b
commit
4e4c6b76a8
|
|
@ -110,7 +110,7 @@ const ToastComponent = (props: ToastProps & { undoAction?: () => void }) => {
|
||||||
return (
|
return (
|
||||||
<ToastBody
|
<ToastBody
|
||||||
variant={props.variant || Variant.info}
|
variant={props.variant || Variant.info}
|
||||||
isUndo={props.onUndo ? true : false}
|
isUndo={!!props.onUndo}
|
||||||
dispatchableAction={props.dispatchableAction}
|
dispatchableAction={props.dispatchableAction}
|
||||||
className="t--toast-action"
|
className="t--toast-action"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,24 @@ const evalErrorHandler = (errors: EvalError[]) => {
|
||||||
errors.forEach((error) => {
|
errors.forEach((error) => {
|
||||||
switch (error.type) {
|
switch (error.type) {
|
||||||
case EvalErrorTypes.DEPENDENCY_ERROR: {
|
case EvalErrorTypes.DEPENDENCY_ERROR: {
|
||||||
Toaster.show({
|
if (error.context) {
|
||||||
text: error.message,
|
// Add more info about node for the toast
|
||||||
variant: Variant.danger,
|
const { node, entityType } = error.context;
|
||||||
});
|
Toaster.show({
|
||||||
Sentry.captureException(new Error(error.message));
|
text: `${error.message} Node was: ${node}`,
|
||||||
|
variant: Variant.danger,
|
||||||
|
});
|
||||||
|
// Send the generic error message to sentry for better grouping
|
||||||
|
Sentry.captureException(new Error(error.message), {
|
||||||
|
tags: {
|
||||||
|
node,
|
||||||
|
entityType,
|
||||||
|
},
|
||||||
|
// Level is warning because it could be a user error
|
||||||
|
level: Sentry.Severity.Warning,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EvalErrorTypes.EVAL_TREE_ERROR: {
|
case EvalErrorTypes.EVAL_TREE_ERROR: {
|
||||||
|
|
|
||||||
|
|
@ -460,9 +460,26 @@ export default class DataTreeEvaluator {
|
||||||
.reverse()
|
.reverse()
|
||||||
.filter((d) => !!d);
|
.filter((d) => !!d);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
// Cyclic dependency found. Extract all node and entity type
|
||||||
|
const node = e.message.match(
|
||||||
|
new RegExp('Cyclic dependency, node was:"(.*)"'),
|
||||||
|
)[1];
|
||||||
|
|
||||||
|
let entityType = "UNKNOWN";
|
||||||
|
const entityName = node.split(".")[0];
|
||||||
|
const entity = _.find(this.oldUnEvalTree, { name: entityName });
|
||||||
|
if (entity && isWidget(entity)) {
|
||||||
|
entityType = entity.type;
|
||||||
|
} else if (entity && isAction(entity)) {
|
||||||
|
entityType = entity.pluginType;
|
||||||
|
}
|
||||||
this.errors.push({
|
this.errors.push({
|
||||||
type: EvalErrorTypes.DEPENDENCY_ERROR,
|
type: EvalErrorTypes.DEPENDENCY_ERROR,
|
||||||
message: e.message,
|
message: "Cyclic dependency found while evaluating.",
|
||||||
|
context: {
|
||||||
|
node,
|
||||||
|
entityType,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
console.error("CYCLICAL DEPENDENCY MAP", dependencyMap);
|
console.error("CYCLICAL DEPENDENCY MAP", dependencyMap);
|
||||||
throw new CrashingError(e.message);
|
throw new CrashingError(e.message);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user