KeyError ======== .. cpp:class:: pandas::KeyError pandas C++ class. Example ------- .. code-block:: cpp #include using namespace pandas; // Use KeyError KeyError obj; // ... operations ... Constructors ------------ .. list-table:: :widths: 55 25 20 :header-rows: 1 * - Signature - Location - Example * - ``explicit KeyError(const std::string& msg) : std::out_of_range(msg)`` - pd_exceptions.h:52 - :ref:`View ` * - ``explicit KeyError(const char\* msg) : std::out_of_range(msg)`` - pd_exceptions.h:53 - :ref:`View ` Code Examples ------------- The following examples are extracted from the test suite. .. _example-keyerror-keyerror-0: .. dropdown:: KeyError (pd_test_5_all.cpp:72949) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 72939 :emphasize-lines: 11 local_fail); } void case_12_key_error_typed_throw_and_isolation(int& local_fail) { std::cout << "-- case_12_key_error_typed_throw_and_isolation\n"; static_assert(std::is_base_of_v, "pandas::KeyError must inherit std::out_of_range"); std::string caught; try { throw pandas::KeyError( std::string(pandas::error_messages::kLabelNotFoundInIndex)); } catch (const std::exception& e) { caught = e.what(); } check_eq_str( "case_12.KeyError_round_trip", "Label not found in index", caught, local_fail); .. _example-keyerror-keyerror-1: .. dropdown:: KeyError (pd_test_5_all.cpp:72949) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 72939 :emphasize-lines: 11 local_fail); } void case_12_key_error_typed_throw_and_isolation(int& local_fail) { std::cout << "-- case_12_key_error_typed_throw_and_isolation\n"; static_assert(std::is_base_of_v, "pandas::KeyError must inherit std::out_of_range"); std::string caught; try { throw pandas::KeyError( std::string(pandas::error_messages::kLabelNotFoundInIndex)); } catch (const std::exception& e) { caught = e.what(); } check_eq_str( "case_12.KeyError_round_trip", "Label not found in index", caught, local_fail);