Преглед на файлове

Fix exception thrower for parsing

Sam Jaffe преди 4 години
родител
ревизия
0daa6c79c7
променени са 1 файла, в които са добавени 8 реда и са изтрити 4 реда
  1. 8 4
      include/program_args/utilities.h

+ 8 - 4
include/program_args/utilities.h

@@ -55,10 +55,14 @@ T convert(std::string const & name, std::string const & data) {
 template <typename T>
 T convert(std::string const & name, std::vector<std::string> const & data) {
   conversion_helper<T> helper;
-  if constexpr (traits::is_repeatable_v<decltype(helper)>) {
-    return helper(data);
-  } else if (data.size() == 1) {
-    return helper(data.front());
+  try {
+    if constexpr (traits::is_repeatable_v<decltype(helper)>) {
+      return helper(data);
+    } else if (data.size() == 1) {
+      return helper(data.front());
+    }
+  } catch (std::exception const & ex) {
+    throw ArgumentStructureError(ex.what(), name);
   }
   throw ArgumentStructureError("Repeated option not allowed", name);
 }