IndexError ========== .. cpp:class:: pandas::IndexError pandas C++ class. Example ------- .. code-block:: cpp #include using namespace pandas; // Create IndexError IndexError idx({1, 2, 3}, "my_index"); size_t len = idx.size(); Constructors ------------ .. list-table:: :widths: 55 25 20 :header-rows: 1 * - Signature - Location - Example * - ``explicit IndexError(const std::string& msg) : std::out_of_range(msg)`` - pd_exceptions.h:45 - :ref:`View ` * - ``explicit IndexError(const char\* msg) : std::out_of_range(msg)`` - pd_exceptions.h:46 - :ref:`View ` Code Examples ------------- The following examples are extracted from the test suite. .. _example-indexerror-indexerror-0: .. dropdown:: IndexError (pd_test_5_all.cpp:72916) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 72906 :emphasize-lines: 11 void case_11_index_error_typed_throw(int& local_fail) { std::cout << "-- case_11_index_error_typed_throw\n"; static_assert(std::is_base_of_v, "pandas::IndexError must inherit std::out_of_range"); static_assert(std::is_base_of_v, "pandas::IndexError must inherit std::exception"); std::string caught; try { throw pandas::IndexError( std::string(pandas::error_messages::kIndexOutOfBounds)); } catch (const std::exception& e) { caught = e.what(); } check_eq_str( "case_11.IndexError_round_trip", "Index out of bounds", caught, local_fail); .. _example-indexerror-indexerror-1: .. dropdown:: IndexError (pd_test_5_all.cpp:72916) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 72906 :emphasize-lines: 11 void case_11_index_error_typed_throw(int& local_fail) { std::cout << "-- case_11_index_error_typed_throw\n"; static_assert(std::is_base_of_v, "pandas::IndexError must inherit std::out_of_range"); static_assert(std::is_base_of_v, "pandas::IndexError must inherit std::exception"); std::string caught; try { throw pandas::IndexError( std::string(pandas::error_messages::kIndexOutOfBounds)); } catch (const std::exception& e) { caught = e.what(); } check_eq_str( "case_11.IndexError_round_trip", "Index out of bounds", caught, local_fail);