Vince's CSV Parser
Loading...
Searching...
No Matches
csv_exceptions.hpp File Reference

Shared exception message templates and throw helpers. More...

#include <set>
#include <stdexcept>
#include <string>
#include <system_error>
#include "common.hpp"

Go to the source code of this file.

Namespaces

namespace  csv
 The all encompassing namespace.
 

Functions

std::string csv::internals::make_prefixed_message (const char *prefix, csv::string_view value)
 
std::string csv::internals::make_unsupported_encoding_message (const char *encoding)
 
std::string csv::internals::make_chunk_size_error (size_t floor, size_t provided)
 
std::string csv::internals::make_chunk_size_ceiling_error (size_t ceiling, size_t provided)
 
std::string csv::internals::make_row_larger_than_chunk_message (size_t chunk_size)
 
std::string csv::internals::make_mmap_failure_message (const std::string &filename, size_t offset, size_t length)
 
std::string csv::internals::make_char_overlap_error (const std::set< char > &offenders)
 
void csv::internals::throw_cannot_open_file (csv::string_view filename)
 
void csv::internals::throw_failed_open_for_writing (const std::string &filename)
 
void csv::internals::throw_unsupported_encoding (const char *encoding)
 
void csv::internals::throw_stream_read_failure ()
 
void csv::internals::throw_mmap_failure (const std::error_code &error, const std::string &filename, size_t offset, size_t length)
 
void csv::internals::throw_row_too_large_for_chunk (size_t chunk_size)
 
void csv::internals::throw_line_too_short (csv::string_view raw_row)
 
void csv::internals::throw_line_too_long (csv::string_view raw_row)
 
void csv::internals::throw_column_not_found (csv::string_view column)
 
void csv::internals::throw_column_not_found_out_of_range (csv::string_view column)
 
void csv::internals::throw_column_index_out_of_bounds ()
 
void csv::internals::throw_column_index_out_of_range ()
 

Variables

CONSTEXPR_VALUE_14 char csv::internals::ERROR_CANNOT_OPEN_FILE [] = "Cannot open file "
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_FAILED_OPEN_WRITE [] = "Failed to open file for writing: "
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_STREAM_READ_FAILURE [] = "StreamParser read failure"
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_UNSUPPORTED_ENCODING_SUFFIX []
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_ROW_TOO_SHORT [] = "Line too short "
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_ROW_TOO_LONG [] = "Line too long "
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_ROW_LARGER_THAN_CHUNK_PREFIX []
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_ROW_LARGER_THAN_CHUNK_SUFFIX []
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_COLUMN_NOT_FOUND [] = "Column not found: "
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_COLUMN_INDEX_OUT_OF_BOUNDS [] = "Column index out of bounds."
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_COLUMN_INDEX_OUT_OF_RANGE [] = "Column index out of range."
 
CONSTEXPR_VALUE_14 char csv::internals::CSV_ERROR_INDEX_OUT_OF_BOUNDS [] = "Index out of bounds."
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_CANNOT_EDIT_CONST_DF_CELL [] = "Cannot edit a const DataFrame cell."
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_CANNOT_ERASE_CONST_DF_ROW [] = "Cannot erase a const DataFrame row."
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_COLUMN_APPLY_STATE_COUNT []
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_COLUMN_APPLY_SUBSET_STATE_COUNT []
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_COLUMN_APPLY_INVALID_INDEX []
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_KEY_COLUMN_EMPTY [] = "Key column cannot be empty."
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_KEY_COLUMN_NOT_FOUND [] = "Key column not found: "
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_KEY_COLUMN_VALUE [] = "Error retrieving key column value: "
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_DUPLICATE_KEY [] = "Duplicate key encountered."
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_UNKEYED_DATA_FRAME []
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_KEY_NOT_FOUND [] = "Key not found."
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_CHUNK_PARALLEL_APPLY_ZERO []
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_READER_NULL_STREAM [] = "CSVReader requires a non-null stream"
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_MULTIPLE_DELIMITERS []
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_CHUNK_SIZE_FLOOR_PREFIX [] = "Chunk size must be at least "
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_CHUNK_SIZE_FLOOR_MIDDLE [] = " bytes (500KB). Provided: "
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_CHUNK_SIZE_CEILING_PREFIX [] = "Chunk size must fit in uint32_t. Maximum: "
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_CHUNK_SIZE_CEILING_MIDDLE [] = ". Provided: "
 
CONSTEXPR_VALUE_14 char csv::internals::ERROR_CHAR_OVERLAP_PREFIX []
 

Detailed Description

Shared exception message templates and throw helpers.

Definition in file csv_exceptions.hpp.

Function Documentation

◆ make_char_overlap_error()

std::string csv::internals::make_char_overlap_error ( const std::set< char > &  offenders)
inline

Definition at line 99 of file csv_exceptions.hpp.

◆ make_chunk_size_ceiling_error()

std::string csv::internals::make_chunk_size_ceiling_error ( size_t  ceiling,
size_t  provided 
)
inline

Definition at line 76 of file csv_exceptions.hpp.

◆ make_chunk_size_error()

std::string csv::internals::make_chunk_size_error ( size_t  floor,
size_t  provided 
)
inline

Definition at line 69 of file csv_exceptions.hpp.

◆ make_mmap_failure_message()

std::string csv::internals::make_mmap_failure_message ( const std::string &  filename,
size_t  offset,
size_t  length 
)
inline

Definition at line 89 of file csv_exceptions.hpp.

◆ make_prefixed_message()

std::string csv::internals::make_prefixed_message ( const char *  prefix,
csv::string_view  value 
)
inline

Definition at line 61 of file csv_exceptions.hpp.

◆ make_row_larger_than_chunk_message()

std::string csv::internals::make_row_larger_than_chunk_message ( size_t  chunk_size)
inline

Definition at line 83 of file csv_exceptions.hpp.

◆ make_unsupported_encoding_message()

std::string csv::internals::make_unsupported_encoding_message ( const char *  encoding)
inline

Definition at line 65 of file csv_exceptions.hpp.

◆ throw_cannot_open_file()

void csv::internals::throw_cannot_open_file ( csv::string_view  filename)
inline

Definition at line 117 of file csv_exceptions.hpp.

◆ throw_column_index_out_of_bounds()

void csv::internals::throw_column_index_out_of_bounds ( )
inline

Definition at line 162 of file csv_exceptions.hpp.

◆ throw_column_index_out_of_range()

void csv::internals::throw_column_index_out_of_range ( )
inline

Definition at line 166 of file csv_exceptions.hpp.

◆ throw_column_not_found()

void csv::internals::throw_column_not_found ( csv::string_view  column)
inline

Definition at line 154 of file csv_exceptions.hpp.

◆ throw_column_not_found_out_of_range()

void csv::internals::throw_column_not_found_out_of_range ( csv::string_view  column)
inline

Definition at line 158 of file csv_exceptions.hpp.

◆ throw_failed_open_for_writing()

void csv::internals::throw_failed_open_for_writing ( const std::string &  filename)
inline

Definition at line 121 of file csv_exceptions.hpp.

◆ throw_line_too_long()

void csv::internals::throw_line_too_long ( csv::string_view  raw_row)
inline

Definition at line 150 of file csv_exceptions.hpp.

◆ throw_line_too_short()

void csv::internals::throw_line_too_short ( csv::string_view  raw_row)
inline

Definition at line 146 of file csv_exceptions.hpp.

◆ throw_mmap_failure()

void csv::internals::throw_mmap_failure ( const std::error_code &  error,
const std::string &  filename,
size_t  offset,
size_t  length 
)
inline

Definition at line 133 of file csv_exceptions.hpp.

◆ throw_row_too_large_for_chunk()

void csv::internals::throw_row_too_large_for_chunk ( size_t  chunk_size)
inline

Definition at line 142 of file csv_exceptions.hpp.

◆ throw_stream_read_failure()

void csv::internals::throw_stream_read_failure ( )
inline

Definition at line 129 of file csv_exceptions.hpp.

◆ throw_unsupported_encoding()

void csv::internals::throw_unsupported_encoding ( const char *  encoding)
inline

Definition at line 125 of file csv_exceptions.hpp.

Variable Documentation

◆ CSV_ERROR_INDEX_OUT_OF_BOUNDS

CONSTEXPR_VALUE_14 char csv::internals::CSV_ERROR_INDEX_OUT_OF_BOUNDS[] = "Index out of bounds."

Definition at line 31 of file csv_exceptions.hpp.

◆ ERROR_CANNOT_EDIT_CONST_DF_CELL

CONSTEXPR_VALUE_14 char csv::internals::ERROR_CANNOT_EDIT_CONST_DF_CELL[] = "Cannot edit a const DataFrame cell."

Definition at line 32 of file csv_exceptions.hpp.

◆ ERROR_CANNOT_ERASE_CONST_DF_ROW

CONSTEXPR_VALUE_14 char csv::internals::ERROR_CANNOT_ERASE_CONST_DF_ROW[] = "Cannot erase a const DataFrame row."

Definition at line 33 of file csv_exceptions.hpp.

◆ ERROR_CANNOT_OPEN_FILE

CONSTEXPR_VALUE_14 char csv::internals::ERROR_CANNOT_OPEN_FILE[] = "Cannot open file "

Definition at line 16 of file csv_exceptions.hpp.

◆ ERROR_CHAR_OVERLAP_PREFIX

CONSTEXPR_VALUE_14 char csv::internals::ERROR_CHAR_OVERLAP_PREFIX[]
Initial value:
=
"There should be no overlap between the quote character, "
"the set of possible delimiters "
"and the set of whitespace characters. Offending characters: "

Definition at line 56 of file csv_exceptions.hpp.

◆ ERROR_CHUNK_PARALLEL_APPLY_ZERO

CONSTEXPR_VALUE_14 char csv::internals::ERROR_CHUNK_PARALLEL_APPLY_ZERO[]
Initial value:
=
"chunk_parallel_apply() requires a non-zero chunk size."

Definition at line 47 of file csv_exceptions.hpp.

◆ ERROR_CHUNK_SIZE_CEILING_MIDDLE

CONSTEXPR_VALUE_14 char csv::internals::ERROR_CHUNK_SIZE_CEILING_MIDDLE[] = ". Provided: "

Definition at line 55 of file csv_exceptions.hpp.

◆ ERROR_CHUNK_SIZE_CEILING_PREFIX

CONSTEXPR_VALUE_14 char csv::internals::ERROR_CHUNK_SIZE_CEILING_PREFIX[] = "Chunk size must fit in uint32_t. Maximum: "

Definition at line 54 of file csv_exceptions.hpp.

◆ ERROR_CHUNK_SIZE_FLOOR_MIDDLE

CONSTEXPR_VALUE_14 char csv::internals::ERROR_CHUNK_SIZE_FLOOR_MIDDLE[] = " bytes (500KB). Provided: "

Definition at line 53 of file csv_exceptions.hpp.

◆ ERROR_CHUNK_SIZE_FLOOR_PREFIX

CONSTEXPR_VALUE_14 char csv::internals::ERROR_CHUNK_SIZE_FLOOR_PREFIX[] = "Chunk size must be at least "

Definition at line 52 of file csv_exceptions.hpp.

◆ ERROR_COLUMN_APPLY_INVALID_INDEX

CONSTEXPR_VALUE_14 char csv::internals::ERROR_COLUMN_APPLY_INVALID_INDEX[]
Initial value:
=
"column_parallel_apply() subset overload received an invalid column index."

Definition at line 38 of file csv_exceptions.hpp.

◆ ERROR_COLUMN_APPLY_STATE_COUNT

CONSTEXPR_VALUE_14 char csv::internals::ERROR_COLUMN_APPLY_STATE_COUNT[]
Initial value:
=
"column_parallel_apply() requires one state object per column."

Definition at line 34 of file csv_exceptions.hpp.

◆ ERROR_COLUMN_APPLY_SUBSET_STATE_COUNT

CONSTEXPR_VALUE_14 char csv::internals::ERROR_COLUMN_APPLY_SUBSET_STATE_COUNT[]
Initial value:
=
"column_parallel_apply() subset overload requires one state object per selected column."

Definition at line 36 of file csv_exceptions.hpp.

◆ ERROR_COLUMN_INDEX_OUT_OF_BOUNDS

CONSTEXPR_VALUE_14 char csv::internals::ERROR_COLUMN_INDEX_OUT_OF_BOUNDS[] = "Column index out of bounds."

Definition at line 29 of file csv_exceptions.hpp.

◆ ERROR_COLUMN_INDEX_OUT_OF_RANGE

CONSTEXPR_VALUE_14 char csv::internals::ERROR_COLUMN_INDEX_OUT_OF_RANGE[] = "Column index out of range."

Definition at line 30 of file csv_exceptions.hpp.

◆ ERROR_COLUMN_NOT_FOUND

CONSTEXPR_VALUE_14 char csv::internals::ERROR_COLUMN_NOT_FOUND[] = "Column not found: "

Definition at line 28 of file csv_exceptions.hpp.

◆ ERROR_DUPLICATE_KEY

CONSTEXPR_VALUE_14 char csv::internals::ERROR_DUPLICATE_KEY[] = "Duplicate key encountered."

Definition at line 43 of file csv_exceptions.hpp.

◆ ERROR_FAILED_OPEN_WRITE

CONSTEXPR_VALUE_14 char csv::internals::ERROR_FAILED_OPEN_WRITE[] = "Failed to open file for writing: "

Definition at line 17 of file csv_exceptions.hpp.

◆ ERROR_KEY_COLUMN_EMPTY

CONSTEXPR_VALUE_14 char csv::internals::ERROR_KEY_COLUMN_EMPTY[] = "Key column cannot be empty."

Definition at line 40 of file csv_exceptions.hpp.

◆ ERROR_KEY_COLUMN_NOT_FOUND

CONSTEXPR_VALUE_14 char csv::internals::ERROR_KEY_COLUMN_NOT_FOUND[] = "Key column not found: "

Definition at line 41 of file csv_exceptions.hpp.

◆ ERROR_KEY_COLUMN_VALUE

CONSTEXPR_VALUE_14 char csv::internals::ERROR_KEY_COLUMN_VALUE[] = "Error retrieving key column value: "

Definition at line 42 of file csv_exceptions.hpp.

◆ ERROR_KEY_NOT_FOUND

CONSTEXPR_VALUE_14 char csv::internals::ERROR_KEY_NOT_FOUND[] = "Key not found."

Definition at line 46 of file csv_exceptions.hpp.

◆ ERROR_MULTIPLE_DELIMITERS

CONSTEXPR_VALUE_14 char csv::internals::ERROR_MULTIPLE_DELIMITERS[]
Initial value:
=
"There is more than one possible delimiter."

Definition at line 50 of file csv_exceptions.hpp.

◆ ERROR_READER_NULL_STREAM

CONSTEXPR_VALUE_14 char csv::internals::ERROR_READER_NULL_STREAM[] = "CSVReader requires a non-null stream"

Definition at line 49 of file csv_exceptions.hpp.

◆ ERROR_ROW_LARGER_THAN_CHUNK_PREFIX

CONSTEXPR_VALUE_14 char csv::internals::ERROR_ROW_LARGER_THAN_CHUNK_PREFIX[]
Initial value:
=
"End of file not reached and no more records parsed. "
"This likely indicates a CSV row larger than the chunk size of "

Definition at line 23 of file csv_exceptions.hpp.

◆ ERROR_ROW_LARGER_THAN_CHUNK_SUFFIX

CONSTEXPR_VALUE_14 char csv::internals::ERROR_ROW_LARGER_THAN_CHUNK_SUFFIX[]
Initial value:
=
" bytes. Use CSVFormat::chunk_size() to increase the chunk size."

Definition at line 26 of file csv_exceptions.hpp.

◆ ERROR_ROW_TOO_LONG

CONSTEXPR_VALUE_14 char csv::internals::ERROR_ROW_TOO_LONG[] = "Line too long "

Definition at line 22 of file csv_exceptions.hpp.

◆ ERROR_ROW_TOO_SHORT

CONSTEXPR_VALUE_14 char csv::internals::ERROR_ROW_TOO_SHORT[] = "Line too short "

Definition at line 21 of file csv_exceptions.hpp.

◆ ERROR_STREAM_READ_FAILURE

CONSTEXPR_VALUE_14 char csv::internals::ERROR_STREAM_READ_FAILURE[] = "StreamParser read failure"

Definition at line 18 of file csv_exceptions.hpp.

◆ ERROR_UNKEYED_DATA_FRAME

CONSTEXPR_VALUE_14 char csv::internals::ERROR_UNKEYED_DATA_FRAME[]
Initial value:
=
"This DataFrame was created without a key column."

Definition at line 44 of file csv_exceptions.hpp.

◆ ERROR_UNSUPPORTED_ENCODING_SUFFIX

CONSTEXPR_VALUE_14 char csv::internals::ERROR_UNSUPPORTED_ENCODING_SUFFIX[]
Initial value:
=
" encoded CSV input is not supported directly. Please transcode to UTF-8 before parsing."

Definition at line 19 of file csv_exceptions.hpp.