41 typedef const char* csv_error_message;
43 static CONSTEXPR_VALUE_14 csv_error_message CSV_CONVERSION_ERROR_MESSAGES[] = {
47 "Attempted to convert a floating point value to an integral type.",
48 "Negative numbers cannot be converted to unsigned types."
54 const size_t index =
static_cast<size_t>(error);
55 return index < (
sizeof(internals::CSV_CONVERSION_ERROR_MESSAGES) /
sizeof(internals::CSV_CONVERSION_ERROR_MESSAGES[0]))
56 ? internals::CSV_CONVERSION_ERROR_MESSAGES[index]
96 std::error_code system;
106 : code(other.code), system(other.system),
context(other.
context) {
109 CSVError(CSVError&& other) noexcept
111 owned_context_(std::move(other.owned_context_)) {
114 CSVError& operator=(
const CSVError& other) {
115 if (
this != &other) {
116 CSVError copy(other);
117 *
this = std::move(copy);
121 CSVError& operator=(CSVError&& other)
noexcept {
122 if (
this != &other) {
124 system = other.system;
126 owned_context_ = std::move(other.owned_context_);
136 error.context = message;
142 std::unique_ptr<char[]> buffer;
143 if (!message.empty()) {
144 buffer.reset(
new char[message.size()]);
145 std::memcpy(buffer.get(), message.data(), message.size());
149 owned_context_ = std::move(buffer);
152 void clear() noexcept {
156 owned_context_.reset();
158 std::string message()
const {
159 const std::string text =
context.empty() ? std::string() : std::string(
context);
160 return system ? text +
": " + system.message() : text;
165 std::unique_ptr<char[]> owned_context_;
168 namespace internals {
170 error = CSVError(code, message);
A standalone header file containing shared code.
The all encompassing namespace.
CSVConversionError
Non-throwing CSVField conversion result.
@ FloatToInt
A floating point field was requested as an integral type.
@ Overflow
The parsed value does not fit in the requested target type.
@ NegativeToUnsigned
A negative value was requested as an unsigned type.
@ None
Conversion succeeded.
@ NotANumber
The field is not compatible with the requested target type.
const char * csv_conversion_error_message(CSVConversionError error) noexcept
Return a stable human-readable description for a CSVConversionError.
CSVErrorCode
Operational failures reported through CSVError.
@ IndexOutOfBounds
A row/column position exceeds the visible schema or physical record width.
@ InvalidArgument
Invalid operation input, such as a null stream or zero batch size.
@ RowTooLarge
A complete record could not fit within the configured read window.
@ WriteFailed
Writing, flushing, or closing the output failed.
@ None
Success, including end-of-stream without a row.
@ ReadFailed
The input stream reported an I/O failure rather than ordinary EOF.
@ KeyColumnProtected
Removing the column that supplies the frame's stored keys is prohibited.
@ UnsupportedEncoding
A UTF-16/UTF-32 BOM was found; transcode the input to UTF-8 first.
@ KeyNotFound
A requested row key is absent from the frame's key index.
@ MappingFailed
A subsequent input-file region could not be memory-mapped; see CSVError::system.
@ RowLengthMismatch
A record's field count violates the configured variable-column policy.
@ SizeLimitExceeded
Combined preserved string-view key bytes exceed std::string::max_size().
@ MissingKeyColumn
Keyed construction has an empty key-column name or a name absent from the schema.
@ InvalidProxy
A proxy is unbound or a column proxy was invalidated by structural mutation.
@ OpenFailed
A native file could not be opened, including initial input mapping.
@ InvalidFormat
Conflicting parsing characters or an unresolved delimiter query.
@ DuplicateKey
A key conflicts with an existing row under the requested insertion/duplicate policy.
@ ColumnNotFound
A requested name is absent from the visible column schema.
@ UnkeyedFrame
A key-based operation was requested on a positional-only frame.
@ ReadOnlyProxy
Mutation was requested through a cell, row, or column without edit permission.
@ InvalidChunkSize
Configured read-window size is outside the supported byte limits.
@ UnsupportedOperation
The operation cannot be performed for this frame, such as inserting into a custom-key frame.
@ ConversionFailed
A DataFrame field/key conversion failed; context describes the cause.
std::string_view string_view
The string_view class used by this library.
A diagnostic whose text remains valid for the lifetime of the error.
csv::string_view context
Diagnostic text; use set_context() to replace it with an owned copy.
static CSVError from_static(CSVErrorCode value, csv::string_view message) noexcept
Borrow text that must remain valid for the program's lifetime.
void set_context(csv::string_view message)
Replace the context with an owned copy; accepts views into this error.
CSVError(CSVErrorCode value, csv::string_view message)
Copy runtime text, including temporary strings and exception messages.