]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
tools: add catches for C++ exceptions
authorWang, Xiang W <xiang.w.wang@intel.com>
Tue, 8 Jan 2019 11:45:31 +0000 (06:45 -0500)
committerChang, Harry <harry.chang@intel.com>
Mon, 21 Jan 2019 01:59:37 +0000 (09:59 +0800)
src/grey.cpp
tools/hsbench/main.cpp

index fa8da2b494d502009e71067d3e472842a91bdd29..86a93d25aaecdbb53bd719d6754733ae6d37ce65 100644 (file)
@@ -198,7 +198,15 @@ void applyGreyOverrides(Grey *g, const string &s) {
 
         string::const_iterator ve = find(ke, pe, ';');
 
-        unsigned int value = lexical_cast<unsigned int>(string(ke + 1, ve));
+        unsigned int value = 0;
+        try {
+            value = lexical_cast<unsigned int>(string(ke + 1, ve));
+        } catch (boost::bad_lexical_cast &e) {
+            printf("Invalid grey override key %s:%s\n", key.c_str(),
+                   string(ke + 1, ve).c_str());
+            invalid_key_seen = true;
+            break;
+        }
         bool done = false;
 
         /* surely there exists a nice template to go with this macro to make
index fecdd3305e1e058adfa3192db3957a0164070dcc..de9fde07d98b3086cbd657e62b72e210589ec856 100644 (file)
@@ -1065,6 +1065,9 @@ int HS_CDECL main(int argc, char *argv[]) {
     } catch (const SqlFailure &f) {
         cerr << f.message << '\n';
         return -1;
+    } catch (const std::runtime_error &e) {
+        cerr << "Internal error: " << e.what() << '\n';
+        return -1;
     }
 
     return 0;