Skip to content

Commit

Permalink
Raise CommunicationFault instead of throwing exception
Browse files Browse the repository at this point in the history
Signed-off-by: Kai-Uwe Hermann <[email protected]>
  • Loading branch information
hikinggrass authored and corneliusclaussen committed Oct 2, 2024
1 parent d0d8ecd commit 5d87bd9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions modules/PN532TokenProvider/main/auth_token_providerImpl.cpp
Original file line number Diff line number Diff line change
@@ -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 <fmt/core.h>

namespace module {
namespace main {

Expand All @@ -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;
}
}
Expand Down

0 comments on commit 5d87bd9

Please sign in to comment.