csv-parser 1.1.0
Csv::Parser (csv-parser)
Loading...
Searching...
No Matches
csv_error.h
Go to the documentation of this file.
1/**************************************************************************
2Copyright: (C) 2021 - 2023 Alexander Shaduri
3License: Zlib
4***************************************************************************/
5
6#ifndef CSV_ERROR_H
7#define CSV_ERROR_H
8
9#include <string>
10#include <stdexcept>
11
12
19namespace Csv {
20
21
22
25class ParseError : public std::runtime_error {
26 public:
27
29 ParseError(std::size_t row, std::size_t column)
30 : runtime_error(createWhatString(row, column)),
31 row_(row), column_(column)
32 { }
33
34
36 [[nodiscard]] std::size_t row() const
37 {
38 return row_;
39 }
40
41
43 [[nodiscard]] std::size_t column() const
44 {
45 return column_;
46 }
47
48
49 private:
50
53 static std::string createWhatString(std::size_t row, std::size_t column)
54 {
55 return std::string("CSV parse error at row ") + std::to_string(row + 1)
56 + ", column " + std::to_string(column + 1);
57 }
58
59
60 std::size_t row_ = 0;
61 std::size_t column_ = 0;
62
63};
64
65
66
67
68} // end ns
69
70
71
72#endif
Exception thrown on CSV parse error.
Definition csv_error.h:25
std::size_t column() const
Return a 0-based column number where error occurred.
Definition csv_error.h:43
std::size_t row() const
Return a 0-based row number where error occurred.
Definition csv_error.h:36
ParseError(std::size_t row, std::size_t column)
Constructor.
Definition csv_error.h:29