diff --git a/app/client/src/sagas/EvaluationsSaga.ts b/app/client/src/sagas/EvaluationsSaga.ts index 47b224258d..55f5c6fb07 100644 --- a/app/client/src/sagas/EvaluationsSaga.ts +++ b/app/client/src/sagas/EvaluationsSaga.ts @@ -15,16 +15,16 @@ import { } from "constants/ReduxActionConstants"; import { getUnevaluatedDataTree } from "selectors/dataTreeSelectors"; import WidgetFactory, { WidgetTypeConfigMap } from "../utils/WidgetFactory"; -import { GracefulWorkerService } from "../utils/WorkerUtil"; +import { GracefulWorkerService } from "utils/WorkerUtil"; import Worker from "worker-loader!../workers/evaluation.worker"; import { EVAL_WORKER_ACTIONS, EvalError, EvalErrorTypes, -} from "../utils/DynamicBindingUtils"; +} from "utils/DynamicBindingUtils"; import log from "loglevel"; -import { WidgetType } from "../constants/WidgetConstants"; -import { WidgetProps } from "../widgets/BaseWidget"; +import { WidgetType } from "constants/WidgetConstants"; +import { WidgetProps } from "widgets/BaseWidget"; import PerformanceTracker, { PerformanceTransactionName, } from "../utils/PerformanceTracker"; @@ -41,22 +41,36 @@ const worker = new GracefulWorkerService(Worker); const evalErrorHandler = (errors: EvalError[]) => { if (!errors) return; errors.forEach((error) => { - if (error.type === EvalErrorTypes.DEPENDENCY_ERROR) { - Toaster.show({ - text: error.message, - variant: Variant.danger, - }); + switch (error.type) { + case EvalErrorTypes.DEPENDENCY_ERROR: { + Toaster.show({ + text: error.message, + variant: Variant.danger, + }); + break; + } + case EvalErrorTypes.EVAL_TREE_ERROR: { + Toaster.show({ + text: "Unexpected error occurred while evaluating the app", + variant: Variant.danger, + }); + break; + } + case EvalErrorTypes.BAD_UNEVAL_TREE_ERROR: { + Sentry.captureException(error); + break; + } + case EvalErrorTypes.EVAL_TRIGGER_ERROR: { + Toaster.show({ + text: `Error occurred when executing trigger: ${error.message}`, + variant: Variant.danger, + }); + break; + } + default: { + Sentry.captureException(error); + } } - if (error.type === EvalErrorTypes.EVAL_TREE_ERROR) { - Toaster.show({ - text: "Unexpected error occurred while evaluating the app", - variant: Variant.danger, - }); - } - if (error.type === EvalErrorTypes.BAD_UNEVAL_TREE_ERROR) { - Sentry.captureException(error); - } - log.debug(error); }); }; diff --git a/app/client/src/utils/DynamicBindingUtils.ts b/app/client/src/utils/DynamicBindingUtils.ts index c769bac4f4..5a2c5691d8 100644 --- a/app/client/src/utils/DynamicBindingUtils.ts +++ b/app/client/src/utils/DynamicBindingUtils.ts @@ -5,7 +5,7 @@ import { } from "constants/BindingsConstants"; import { Action } from "entities/Action"; import moment from "moment-timezone"; -import { WidgetProps } from "../widgets/BaseWidget"; +import { WidgetProps } from "widgets/BaseWidget"; import parser from "fast-xml-parser"; export type DependencyMap = Record>; @@ -91,6 +91,7 @@ export enum EvalErrorTypes { EVAL_ERROR = "EVAL_ERROR", UNKNOWN_ERROR = "UNKNOWN_ERROR", BAD_UNEVAL_TREE_ERROR = "BAD_UNEVAL_TREE_ERROR", + EVAL_TRIGGER_ERROR = "EVAL_TRIGGER_ERROR", } export type EvalError = { diff --git a/app/client/src/workers/evaluation.worker.ts b/app/client/src/workers/evaluation.worker.ts index aaa1f30778..560815d4b6 100644 --- a/app/client/src/workers/evaluation.worker.ts +++ b/app/client/src/workers/evaluation.worker.ts @@ -19,11 +19,11 @@ import { isPathADynamicBinding, isPathADynamicTrigger, unsafeFunctionForEval, -} from "../utils/DynamicBindingUtils"; +} from "utils/DynamicBindingUtils"; import _ from "lodash"; -import { WidgetTypeConfigMap } from "../utils/WidgetFactory"; +import { WidgetTypeConfigMap } from "utils/WidgetFactory"; import toposort from "toposort"; -import { DATA_BIND_REGEX } from "../constants/BindingsConstants"; +import { DATA_BIND_REGEX } from "constants/BindingsConstants"; import equal from "fast-deep-equal/es6"; import unescapeJS from "unescape-js"; @@ -46,7 +46,7 @@ import { import { EXECUTION_PARAM_KEY, EXECUTION_PARAM_REFERENCE_REGEX, -} from "../constants/ActionConstants"; +} from "constants/ActionConstants"; const ctx: Worker = self as any; @@ -152,7 +152,17 @@ ctx.addEventListener( callbackData, ); const cleanTriggers = removeFunctions(triggers); - const errors = dataTreeEvaluator.errors; + // Transforming eval errors into eval trigger errors. Since trigger + // errors occur less, we want to treat it separately + const errors = dataTreeEvaluator.errors.map((error) => { + if (error.type === EvalErrorTypes.EVAL_ERROR) { + return { + ...error, + type: EvalErrorTypes.EVAL_TRIGGER_ERROR, + }; + } + return error; + }); dataTreeEvaluator.clearErrors(); return { triggers: cleanTriggers, errors }; }