## Description Adding feature flags to Lint and Eval workers which will be used to compute the feature in EE #### PR fixes following issue(s) Fixes #https://github.com/appsmithorg/appsmith-ee/issues/1905 #### Type of change > Please delete options that are not relevant. - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [ ] JUnit - [ ] Jest - [x] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
143 lines
4.2 KiB
TypeScript
143 lines
4.2 KiB
TypeScript
import {
|
|
createMessage,
|
|
TRIGGER_ACTION_VALIDATION_ERROR,
|
|
} from "@appsmith/constants/messages";
|
|
import type { ApiResponse } from "api/ApiResponses";
|
|
import { isString } from "lodash";
|
|
import type { Types } from "utils/TypeHelpers";
|
|
import type { ActionTriggerKeys } from "@appsmith/workers/Evaluation/fns/index";
|
|
import { getActionTriggerFunctionNames } from "@appsmith/workers/Evaluation/fns/index";
|
|
import { getAppMode } from "@appsmith/selectors/applicationSelectors";
|
|
import AnalyticsUtil from "../../utils/AnalyticsUtil";
|
|
import {
|
|
setDebuggerSelectedTab,
|
|
showDebugger,
|
|
} from "../../actions/debuggerActions";
|
|
import { DEBUGGER_TAB_KEYS } from "../../components/editorComponents/Debugger/helpers";
|
|
import store from "store";
|
|
import showToast from "sagas/ToastSagas";
|
|
import { call } from "redux-saga/effects";
|
|
|
|
/*
|
|
* The base trigger error that also logs the errors in the debugger.
|
|
* Extend this error to make custom handling of errors
|
|
*/
|
|
export class TriggerFailureError extends Error {
|
|
error?: Error;
|
|
|
|
constructor(reason: string, error?: Error) {
|
|
super(reason);
|
|
this.error = error;
|
|
}
|
|
}
|
|
|
|
export class PluginTriggerFailureError extends TriggerFailureError {
|
|
responseData: unknown[] = [];
|
|
|
|
constructor(reason: string, responseData: unknown[]) {
|
|
super(reason);
|
|
this.responseData = responseData;
|
|
}
|
|
}
|
|
|
|
export class ActionValidationError extends TriggerFailureError {
|
|
constructor(
|
|
functionName: ActionTriggerKeys,
|
|
argumentName: string,
|
|
expectedType: Types,
|
|
received: Types,
|
|
) {
|
|
const errorMessage = createMessage(
|
|
TRIGGER_ACTION_VALIDATION_ERROR,
|
|
getActionTriggerFunctionNames()[functionName],
|
|
argumentName,
|
|
expectedType,
|
|
received,
|
|
);
|
|
super(errorMessage);
|
|
}
|
|
}
|
|
|
|
export function* logActionExecutionError(
|
|
errorMessage: string,
|
|
isExecuteJSFunc = true,
|
|
) {
|
|
//Commenting as per decision taken for the error hanlding epic to not show the trigger errors in the debugger.
|
|
// if (triggerPropertyName) {
|
|
// AppsmithConsole.addErrors([
|
|
// {
|
|
// payload: {
|
|
// id: `${source?.id}-${triggerPropertyName}`,
|
|
// logType: LOG_TYPE.TRIGGER_EVAL_ERROR,
|
|
// text: createMessage(DEBUGGER_TRIGGER_ERROR, triggerPropertyName),
|
|
// source: {
|
|
// type: ENTITY_TYPE.WIDGET,
|
|
// id: source?.id ?? "",
|
|
// name: source?.name ?? "",
|
|
// propertyPath: triggerPropertyName,
|
|
// },
|
|
// messages: [
|
|
// {
|
|
// type: errorType,
|
|
// message: { name: "TriggerExecutionError", message: errorMessage },
|
|
// },
|
|
// ],
|
|
// },
|
|
// },
|
|
// ]);
|
|
// }
|
|
|
|
function onDebugClick() {
|
|
const appMode = getAppMode(store.getState());
|
|
if (appMode === "PUBLISHED") return null;
|
|
|
|
AnalyticsUtil.logEvent("OPEN_DEBUGGER", {
|
|
source: "TOAST",
|
|
});
|
|
store.dispatch(showDebugger(true));
|
|
store.dispatch(setDebuggerSelectedTab(DEBUGGER_TAB_KEYS.ERROR_TAB));
|
|
}
|
|
|
|
if (isExecuteJSFunc)
|
|
// This is the toast that is rendered when any unhandled error occurs in JS object.
|
|
yield call(showToast, errorMessage, {
|
|
kind: "error",
|
|
action: {
|
|
text: "debug",
|
|
effect: () => onDebugClick(),
|
|
className: "t--toast-debug-button",
|
|
},
|
|
});
|
|
}
|
|
|
|
/*
|
|
* Thrown when action execution fails for some reason
|
|
* */
|
|
export class PluginActionExecutionError extends Error {
|
|
response?: ApiResponse;
|
|
userCancelled: boolean;
|
|
|
|
constructor(message: string, userCancelled: boolean, response?: ApiResponse) {
|
|
super(message);
|
|
this.name = "PluginActionExecutionError";
|
|
this.userCancelled = userCancelled;
|
|
this.response = response;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* The user cancelled the run of this action in a confirmation modal.
|
|
* This modal is shown if an action has a confirmation setting enabled.
|
|
* If they cancel, bail, dont show errors and dont run anything further
|
|
*/
|
|
export class UserCancelledActionExecutionError extends PluginActionExecutionError {
|
|
constructor() {
|
|
super("User cancelled action execution", true);
|
|
this.name = "UserCancelledActionExecutionError";
|
|
}
|
|
}
|
|
|
|
export const getErrorAsString = (error: unknown): string => {
|
|
return isString(error) ? error : JSON.stringify(error);
|
|
};
|