From 22b5e665ad330cd8a14bb43d56faa0ac2b16b55a Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Thu, 12 Oct 2023 16:06:30 +0200 Subject: [PATCH] DeckLink disp.: user-friendly error when stoi throws --- src/video_display/decklink.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/video_display/decklink.cpp b/src/video_display/decklink.cpp index 83d0a5e60..e2ab8962d 100644 --- a/src/video_display/decklink.cpp +++ b/src/video_display/decklink.cpp @@ -1268,7 +1268,18 @@ static void *display_decklink_init(struct module *parent, const char *fmt, unsig auto *s = new state_decklink(); s->audio_drift_fixer.set_root(get_root_module(parent)); - if (!settings_init(s, fmt, cardId, &audio_consumer_levels)) { + bool succeeded = false; + try { + succeeded = settings_init(s, fmt, cardId, &audio_consumer_levels); + } catch (logic_error &e) { + if (strcmp(e.what(), "stoi") != 0 && + strcmp(e.what(), "stod") != 0) { + throw; + } + MSG(ERROR, + "Invalid number passed where numeric argument expected!\n"); + } + if (!succeeded) { delete s; return NULL; }