diff --git a/app/client/src/sagas/ActionExecution/PluginActionSaga.ts b/app/client/src/sagas/ActionExecution/PluginActionSaga.ts index 9d748bb7bc..00fd7bffb4 100644 --- a/app/client/src/sagas/ActionExecution/PluginActionSaga.ts +++ b/app/client/src/sagas/ActionExecution/PluginActionSaga.ts @@ -641,7 +641,15 @@ export default function* executePluginActionTriggerSaga( } else { throw new PluginTriggerFailureError( createMessage(ERROR_PLUGIN_ACTION_EXECUTE, pluginActionNameToDisplay), - [], + [ + payload.body, + params, + { + isExecutionSuccess: payload.isExecutionSuccess, + statusCode: payload.statusCode, + headers: payload.headers, + }, + ], ); } } else { diff --git a/app/client/src/sagas/EvaluationsSaga.ts b/app/client/src/sagas/EvaluationsSaga.ts index dcfab0a378..f975ccd229 100644 --- a/app/client/src/sagas/EvaluationsSaga.ts +++ b/app/client/src/sagas/EvaluationsSaga.ts @@ -531,8 +531,15 @@ export function* executeTriggerRequestSaga( // a success: false is sent to reject the promise // @ts-expect-error: reason is of type string responsePayload.error = { - // @ts-expect-error: reason is of type string - message: error.responseData?.[0] || error.message, + message: + // @ts-expect-error: reason is of type string + error.responseData?.[0] && typeof error.responseData?.[0] === "string" + ? // @ts-expect-error: reason is of type string + error.responseData?.[0] + : // @ts-expect-error: reason is of type string + error.message, + // @ts-expect-error: responseData is of type array + responseData: error.responseData || [], }; } diff --git a/app/client/src/workers/Evaluation/fns/actionFns.ts b/app/client/src/workers/Evaluation/fns/actionFns.ts index 860c4f9d4b..7eb57b4fb1 100644 --- a/app/client/src/workers/Evaluation/fns/actionFns.ts +++ b/app/client/src/workers/Evaluation/fns/actionFns.ts @@ -68,6 +68,27 @@ export default async function run( * */ return response[0]; } catch (e) { + const error = { + // TODO: Fix this the next time the file is edited + // eslint-disable-next-line @typescript-eslint/no-explicit-any + message: (e as any).message, + }; + + // If error contains responseData, update action data and responseMeta before throwing + // @ts-expect-error: responseData is a custom property + if (e.responseData && e.responseData.length > 0) { + // @ts-expect-error: self type is not defined + const action = self[this.name] as ActionEntity; + // @ts-expect-error: responseData is array format + const responseData = e.responseData; + + if (action && responseData.length >= 3) { + action.data = responseData[0]; // error response body + action.responseMeta = responseData[2]; // { isExecutionSuccess, statusCode, headers } + action.isLoading = false; + } + } + if (typeof onError === "function") { // TODO: Fix this the next time the file is edited // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -76,7 +97,7 @@ export default async function run( return; } - throw e; + throw error; } }