Skip to content

Commit 3e7cd4a

Browse files
authored
Merge pull request #3471 from hannes-steffenhagen-diffblue/string-split-throw-instead-of-assert
Make split_string check&throw instead of assert return value
2 parents 9cf2bfb + 19babdc commit 3e7cd4a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/util/string_utils.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Author: Daniel Poetzl
77
\*******************************************************************/
88

99
#include "string_utils.h"
10+
#include "exception_utils.h"
1011
#include "invariant.h"
1112

1213
#include <cassert>
@@ -109,7 +110,14 @@ void split_string(
109110
std::vector<std::string> result;
110111

111112
split_string(s, delim, result, strip);
112-
CHECK_RETURN(result.size() == 2);
113+
if(result.size() != 2)
114+
{
115+
throw deserialization_exceptiont{"expected string `" + s +
116+
"' to contain two substrings "
117+
"delimited by " +
118+
delim + " but has " +
119+
std::to_string(result.size())};
120+
}
113121

114122
left=result[0];
115123
right=result[1];

0 commit comments

Comments
 (0)