Update parser exception handling for invalid split/conversion

This commit is contained in:
ado 2023-08-06 14:04:21 +02:00
parent 77a69fbd6d
commit a378998e34

View File

@ -98,9 +98,9 @@ public:
if constexpr (throw_on_error) { if constexpr (throw_on_error) {
try { try {
reader_.parse(); reader_.parse();
} catch (...) { } catch (const ss::exception& e) {
read_line(); read_line();
throw; decorate_rethrow(e);
} }
} else { } else {
reader_.parse(); reader_.parse();
@ -126,9 +126,9 @@ public:
auto value = reader_.converter_.template convert<T, Ts...>(); auto value = reader_.converter_.template convert<T, Ts...>();
read_line(); read_line();
return value; return value;
} catch (...) { } catch (const ss::exception& e) {
read_line(); read_line();
throw; decorate_rethrow(e);
} }
} }
@ -597,6 +597,16 @@ private:
} }
} }
void decorate_rethrow(const ss::exception& e) const {
static_assert(throw_on_error,
"throw_on_error needs to be enabled to use this method");
throw ss::exception{std::string{file_name_}
.append(" ")
.append(std::to_string(reader_.line_number_))
.append(": ")
.append(e.what())};
}
//////////////// ////////////////
// line reading // line reading
//////////////// ////////////////