mirror of
https://github.com/red0124/ssp.git
synced 2025-01-23 13:05:20 +01:00
Make line method work on errors too
This commit is contained in:
parent
6b4f456654
commit
7df96d95c7
@ -84,9 +84,9 @@ public:
|
|||||||
return to_object<T>(get_next<Ts...>());
|
return to_object<T>(get_next<Ts...>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO make the method work with if valid() returns false
|
|
||||||
size_t line() const {
|
size_t line() const {
|
||||||
return valid() ? reader_.line_number_ - 1 : 0;
|
return reader_.line_number_ > 1 ? reader_.line_number_ - 1
|
||||||
|
: reader_.line_number_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename... Ts>
|
template <typename T, typename... Ts>
|
||||||
@ -193,7 +193,7 @@ public:
|
|||||||
reader_.next_line_converter_.set_column_mapping(column_mappings,
|
reader_.next_line_converter_.set_column_mapping(column_mappings,
|
||||||
header_.size());
|
header_.size());
|
||||||
|
|
||||||
if (line() == 0) {
|
if (line() == 1) {
|
||||||
ignore_next();
|
ignore_next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -622,11 +622,9 @@ private:
|
|||||||
void decorate_rethrow(const ss::exception& e) const {
|
void decorate_rethrow(const ss::exception& e) const {
|
||||||
static_assert(throw_on_error,
|
static_assert(throw_on_error,
|
||||||
"throw_on_error needs to be enabled to use this method");
|
"throw_on_error needs to be enabled to use this method");
|
||||||
auto line = reader_.line_number_;
|
throw ss::exception{std::string{file_name_}
|
||||||
throw ss::exception{
|
|
||||||
std::string{file_name_}
|
|
||||||
.append(" ")
|
.append(" ")
|
||||||
.append(std::to_string(line > 1 ? line - 1 : line))
|
.append(std::to_string(line()))
|
||||||
.append(": ")
|
.append(": ")
|
||||||
.append(e.what())};
|
.append(e.what())};
|
||||||
}
|
}
|
||||||
|
7
ssp.hpp
7
ssp.hpp
@ -2386,9 +2386,9 @@ public:
|
|||||||
return to_object<T>(get_next<Ts...>());
|
return to_object<T>(get_next<Ts...>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO make the method work with if valid() returns false
|
|
||||||
size_t line() const {
|
size_t line() const {
|
||||||
return valid() ? reader_.line_number_ - 1 : 0;
|
return reader_.line_number_ > 1 ? reader_.line_number_ - 1
|
||||||
|
: reader_.line_number_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename... Ts>
|
template <typename T, typename... Ts>
|
||||||
@ -2924,11 +2924,10 @@ private:
|
|||||||
void decorate_rethrow(const ss::exception& e) const {
|
void decorate_rethrow(const ss::exception& e) const {
|
||||||
static_assert(throw_on_error,
|
static_assert(throw_on_error,
|
||||||
"throw_on_error needs to be enabled to use this method");
|
"throw_on_error needs to be enabled to use this method");
|
||||||
auto line = reader_.line_number_;
|
|
||||||
throw ss::exception{
|
throw ss::exception{
|
||||||
std::string{file_name_}
|
std::string{file_name_}
|
||||||
.append(" ")
|
.append(" ")
|
||||||
.append(std::to_string(line > 1 ? line - 1 : line))
|
.append(std::to_string(line()))
|
||||||
.append(": ")
|
.append(": ")
|
||||||
.append(e.what())};
|
.append(e.what())};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user