mirror of
https://github.com/red0124/ssp.git
synced 2025-01-23 04:55:20 +01:00
Update parser exception handling for invalid split/conversion
This commit is contained in:
parent
77a69fbd6d
commit
a378998e34
@ -98,9 +98,9 @@ public:
|
||||
if constexpr (throw_on_error) {
|
||||
try {
|
||||
reader_.parse();
|
||||
} catch (...) {
|
||||
} catch (const ss::exception& e) {
|
||||
read_line();
|
||||
throw;
|
||||
decorate_rethrow(e);
|
||||
}
|
||||
} else {
|
||||
reader_.parse();
|
||||
@ -126,9 +126,9 @@ public:
|
||||
auto value = reader_.converter_.template convert<T, Ts...>();
|
||||
read_line();
|
||||
return value;
|
||||
} catch (...) {
|
||||
} catch (const ss::exception& e) {
|
||||
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
|
||||
////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user