From 5d87bd9f4a486259ab9bd00956041d9e95a9b3fa Mon Sep 17 00:00:00 2001 From: Kai-Uwe Hermann Date: Wed, 25 Sep 2024 11:56:45 +0200 Subject: [PATCH] Raise CommunicationFault instead of throwing exception Signed-off-by: Kai-Uwe Hermann --- .../main/auth_token_providerImpl.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/PN532TokenProvider/main/auth_token_providerImpl.cpp b/modules/PN532TokenProvider/main/auth_token_providerImpl.cpp index 7391069f0..2d40b85db 100644 --- a/modules/PN532TokenProvider/main/auth_token_providerImpl.cpp +++ b/modules/PN532TokenProvider/main/auth_token_providerImpl.cpp @@ -1,8 +1,10 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2022 - 2022 Pionix GmbH and Contributors to EVerest +// Copyright Pionix GmbH and Contributors to EVerest #include "auth_token_providerImpl.hpp" +#include + namespace module { namespace main { @@ -13,8 +15,13 @@ void auth_token_providerImpl::init() { EVLOG_info << "Serial port: " << config.serial_port << " baud rate: " << config.baud_rate; } if (!serial.openDevice(config.serial_port.c_str(), config.baud_rate)) { - EVLOG_AND_THROW(EVEXCEPTION(Everest::EverestConfigError, "Could not open serial port ", config.serial_port, - " with baud rate ", config.baud_rate)); + if (!this->error_state_monitor->is_error_active("generic/CommunicationFault", "Communication timed out")) { + auto error_message = + fmt::format("Could not open serial port {} with baud rate {}", config.serial_port, config.baud_rate); + auto error = this->error_factory->create_error("generic/CommunicationFault", "Communication timed out", + error_message); + raise_error(error); + } return; } }