From 5a9c0deb45c0e204c3c539ae21c3d3e0a5e6f2c2 Mon Sep 17 00:00:00 2001 From: Guido Modarelli Date: Thu, 12 Dec 2024 12:21:56 -0300 Subject: [PATCH] fix(logging): improve error handling by explicitly casting error to Error for better clarity in data source alerts handling --- .../public/services/state/containers/data-source-alerts.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/wazuh-core/public/services/state/containers/data-source-alerts.ts b/plugins/wazuh-core/public/services/state/containers/data-source-alerts.ts index b9fe07b0f8..07c5a836a1 100644 --- a/plugins/wazuh-core/public/services/state/containers/data-source-alerts.ts +++ b/plugins/wazuh-core/public/services/state/containers/data-source-alerts.ts @@ -53,7 +53,7 @@ export class DataSourceAlertsStateContainer implements StateContainer { return result; } catch (error) { - this.logger.error(`Error getting data: ${error.message}`); + this.logger.error(`Error getting data: ${(error as Error).message}`); throw error; } } @@ -78,7 +78,7 @@ export class DataSourceAlertsStateContainer implements StateContainer { this.logger.debug(`Encoded data was set: ${encodedData}`); } } catch (error) { - this.logger.error(`Error setting data: ${error.message}`); + this.logger.error(`Error setting data: ${(error as Error).message}`); // TODO: implement // const options = { // context: `${AppState.name}.setClusterInfo`, @@ -106,7 +106,7 @@ export class DataSourceAlertsStateContainer implements StateContainer { return result; } catch (error) { - this.logger.error(error.message); + this.logger.error((error as Error).message); throw error; } }