From 946229bb6e32e03e0e5e1b387a822c25a0b1dfba Mon Sep 17 00:00:00 2001 From: Clemente Raposo Date: Fri, 17 Jan 2025 11:24:52 +0000 Subject: [PATCH] Add support for default error messages in async action --- .../processes/async-action/async-action.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/core/app/core/src/lib/services/process/processes/async-action/async-action.ts b/core/app/core/src/lib/services/process/processes/async-action/async-action.ts index 500ec2ec0..4677ca31f 100644 --- a/core/app/core/src/lib/services/process/processes/async-action/async-action.ts +++ b/core/app/core/src/lib/services/process/processes/async-action/async-action.ts @@ -85,9 +85,10 @@ export class AsyncActionService { * @param {string} actionName to submit * @param {string} data to send * @param {string} presetHandlerKey to use + * @param params * @returns {object} Observable */ - public run(actionName: string, data: AsyncActionInput, presetHandlerKey: string = null): Observable { + public run(actionName: string, data: AsyncActionInput, presetHandlerKey: string = null, params: any = null): Observable { const options = { ...data }; @@ -142,8 +143,20 @@ export class AsyncActionService { return of(null); } - this.message.addDangerMessageByKey('LBL_ACTION_ERROR'); this.appStateStore.updateLoading(actionName, false); + + if (params?.errorMessageLabel ?? false) { + this.message.addDangerMessage(params?.errorMessageLabel); + return of(null); + } + + if (params?.errorMessageLabelKey ?? false) { + this.message.addDangerMessageByKey(params?.errorMessageLabelKey, 'Unexpected error when calling action, please contact your system administrator.'); + return of(null); + } + + this.message.addDangerMessageByKey('LBL_ACTION_ERROR', 'Unexpected error when calling action, please contact your system administrator.'); + return of(null); }), );