From 548187f48dae0f5abba1801dd11e6de2bf3540c6 Mon Sep 17 00:00:00 2001 From: Kristofer Berggren Date: Sat, 28 Oct 2023 18:49:20 +0800 Subject: [PATCH] improved logging when protocol library fails to load --- lib/common/src/version.h | 2 +- src/main.cpp | 18 ++++++++++++++---- src/nchat.1 | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/common/src/version.h b/lib/common/src/version.h index 622d9eee..fe91de96 100644 --- a/lib/common/src/version.h +++ b/lib/common/src/version.h @@ -7,4 +7,4 @@ #pragma once -#define NCHAT_VERSION "3.94" +#define NCHAT_VERSION "3.95" diff --git a/src/main.cpp b/src/main.cpp index 4359e861..7b709f4e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -72,6 +72,13 @@ class ProtocolFactory : public ProtocolBaseFactory if (handle == nullptr) { LOG_ERROR("failed dlopen %s", libPath.c_str()); + const char* dlerr = dlerror(); + if (dlerr != nullptr) + { + LOG_ERROR("dlerror %s", dlerr); + } + + std::cout << "Failed to load " << libPath << ", skipping profile.\n"; return protocol; } @@ -299,9 +306,12 @@ int main(int argc, char* argv[]) { LOG_DEBUG("loading existing profile %s", profileId.c_str()); std::shared_ptr protocol = protocolFactory->Create(); - protocol->LoadProfile(profilesDir, profileId); - ui->AddProtocol(protocol); - found = true; + if (protocol) + { + protocol->LoadProfile(profilesDir, profileId); + ui->AddProtocol(protocol); + found = true; + } } } @@ -355,7 +365,7 @@ int main(int argc, char* argv[]) int rv = 0; if (!hasProtocols) { - std::cout << "no profiles setup, exiting.\n"; + std::cout << "No profiles setup, exiting.\n"; rv = 1; } diff --git a/src/nchat.1 b/src/nchat.1 index be5ee387..60c592cc 100644 --- a/src/nchat.1 +++ b/src/nchat.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man. -.TH NCHAT "1" "October 2023" "nchat v3.94" "User Commands" +.TH NCHAT "1" "October 2023" "nchat v3.95" "User Commands" .SH NAME nchat \- ncurses chat .SH SYNOPSIS