ValueError ========== .. cpp:class:: pandas::ValueError pandas C++ class. Example ------- .. code-block:: cpp #include using namespace pandas; // Use ValueError ValueError obj; // ... operations ... Constructors ------------ .. list-table:: :widths: 55 25 20 :header-rows: 1 * - Signature - Location - Example * - ``explicit ValueError(const std::string& msg) : std::invalid_argument(msg)`` - pd_exceptions.h:28 - :ref:`View ` * - ``explicit ValueError(const char\* msg) : std::invalid_argument(msg)`` - pd_exceptions.h:29 - :ref:`View ` Code Examples ------------- The following examples are extracted from the test suite. .. _example-valueerror-valueerror-0: .. dropdown:: ValueError (pd_test_5_all.cpp:72279) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 72269 :emphasize-lines: 11 } void case_5_reindex_migration_acceptance(int& local_fail) { std::cout << "-- case_5_reindex_migration_acceptance\n"; // Pre-migration form (what the 8 sites currently emit). const std::string pre_what = "cannot reindex on an axis with duplicate labels"; // Post-migration form (what the registry call emits). std::string post_what; try { throw pandas::ValueError( std::string(pandas::error_messages::kCannotReindexDuplicate)); } catch (const std::exception& e) { post_what = e.what(); } check_eq_str("case_5.reindex_what_byte_equal", pre_what, post_what, local_fail); } void case_6_throw_via_registry(int& local_fail) { std::cout << "-- case_6_throw_via_registry\n"; std::string caught; .. _example-valueerror-valueerror-1: .. dropdown:: ValueError (pd_test_5_all.cpp:72279) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 72269 :emphasize-lines: 11 } void case_5_reindex_migration_acceptance(int& local_fail) { std::cout << "-- case_5_reindex_migration_acceptance\n"; // Pre-migration form (what the 8 sites currently emit). const std::string pre_what = "cannot reindex on an axis with duplicate labels"; // Post-migration form (what the registry call emits). std::string post_what; try { throw pandas::ValueError( std::string(pandas::error_messages::kCannotReindexDuplicate)); } catch (const std::exception& e) { post_what = e.what(); } check_eq_str("case_5.reindex_what_byte_equal", pre_what, post_what, local_fail); } void case_6_throw_via_registry(int& local_fail) { std::cout << "-- case_6_throw_via_registry\n"; std::string caught;