Skip to content

Commit

Permalink
Merge pull request #16 from doug1234/HandlingErrors
Browse files Browse the repository at this point in the history
Now throwing for some dds initialization errors instead of exiting
  • Loading branch information
jrw972 authored Dec 7, 2023
2 parents 013e6e7 + e441c98 commit e346cf7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
uses: lukka/run-vcpkg@v10
with:
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
vcpkgGitCommitId: 688ece714204fb5e9ad790ad9ad6d9f571d2b032
vcpkgGitCommitId: 8eb57355a4ffb410a2e94c07b4dca2dffbee8e50
runVcpkgInstall: true

# Set Up Build Environments
Expand Down
14 changes: 4 additions & 10 deletions src/dds_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,10 @@ bool DDSManager::joinDomain(const int& domainID, const std::string& config, std:

ACE_Ini_ImpExp import(heap);
if (0 != import.import_config(dds_config_file_str.c_str())) {
std::cerr << "Unable to open " << dds_config_file_str.c_str() << ". "
<< "Specify the correct path in DDSManager::joinDomain, "
<< "set the 'DDS_CONFIG_FILE' environment variable, or "
<< "copy the DDS configuration file into the working dir."
<< "\n\nThe application will now exit :("
<< std::endl;

// Allow some time for the user to see the message before exit
std::this_thread::sleep_for(std::chrono::seconds(5));
exit(1);
const std::string error = "Unable to open " + dds_config_file_str + ". "
+ "Set the 'DDS_CONFIG_FILE' environment variable or "
+ "copy the DDS configuration file into the working dir.";
throw std::runtime_error(error);
}

// Process common (no section) data here.
Expand Down
6 changes: 6 additions & 0 deletions src/dds_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ bool DDSManager::registerTopic(const std::string& topicName, const STD_QOS::QosT
status = ts->register_type(m_domainParticipant, tn.in());
checkStatus(status, "register_type");

// Make sure the topic actually registered. If not, there was an issue in the config file
if (m_domainParticipant == nullptr)
{
throw std::runtime_error("Failed to initialize domain participant. Is there an error in your OpenDDS.ini file?");
}

topicGroup->typeName = tn;


Expand Down

0 comments on commit e346cf7

Please sign in to comment.