## Description This PR updates the error logs - Establishing a consistent format for all error messages. - Revising error titles and details for improved understanding. - Compiling internal documentation of all error categories, subcategories, and error descriptions. Updated Error Interface: https://www.notion.so/appsmith/Error-Interface-for-Plugin-Execution-Error-7b3f5323ba4c40bfad281ae717ccf79b PRD: https://www.notion.so/appsmith/PRD-Error-Handling-Framework-4ac9747057fd4105a9d52cb8b42f4452?pvs=4#008e9c79ff3c484abf0250a5416cf052 >TL;DR Fixes # Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: subrata <subrata@appsmith.com>
135 lines
3.7 KiB
TypeScript
135 lines
3.7 KiB
TypeScript
import { TriggerSource } from "constants/AppsmithActionConstants/ActionConstants";
|
|
import {
|
|
createMessage,
|
|
TRIGGER_ACTION_VALIDATION_ERROR,
|
|
} from "@appsmith/constants/messages";
|
|
import { Toaster, Variant } from "design-system-old";
|
|
import { ApiResponse } from "api/ApiResponses";
|
|
import { isString } from "lodash";
|
|
import { Types } from "utils/TypeHelpers";
|
|
import {
|
|
ActionTriggerFunctionNames,
|
|
ActionTriggerKeys,
|
|
} from "@appsmith/workers/Evaluation/fns/index";
|
|
import DebugButton from "components/editorComponents/Debugger/DebugCTA";
|
|
|
|
/*
|
|
* 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,
|
|
ActionTriggerFunctionNames[functionName],
|
|
argumentName,
|
|
expectedType,
|
|
received,
|
|
);
|
|
super(errorMessage);
|
|
}
|
|
}
|
|
|
|
export const logActionExecutionError = (
|
|
errorMessage: string,
|
|
source?: TriggerSource,
|
|
triggerPropertyName?: string,
|
|
) => {
|
|
//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 },
|
|
// },
|
|
// ],
|
|
// },
|
|
// },
|
|
// ]);
|
|
// }
|
|
|
|
Toaster.show({
|
|
text: errorMessage,
|
|
variant: Variant.danger,
|
|
showDebugButton: !!triggerPropertyName && {
|
|
component: DebugButton,
|
|
componentProps: {
|
|
className: "t--toast-debug-button",
|
|
source: "TOAST",
|
|
},
|
|
},
|
|
});
|
|
};
|
|
|
|
/*
|
|
* 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 class UncaughtPromiseError extends Error {
|
|
constructor(message: string) {
|
|
super(message);
|
|
}
|
|
}
|
|
|
|
export const getErrorAsString = (error: unknown): string => {
|
|
return isString(error) ? error : JSON.stringify(error);
|
|
};
|