| 695 | }; |
| 696 | |
| 697 | inline str format_message_key_error_key_object(handle py_key) { |
| 698 | str message = "pybind11::bind_map key"; |
| 699 | if (!py_key) { |
| 700 | return message; |
| 701 | } |
| 702 | try { |
| 703 | message = str(py_key); |
| 704 | } catch (const std::exception &) { |
| 705 | try { |
| 706 | message = repr(py_key); |
| 707 | } catch (const std::exception &) { |
| 708 | return message; |
| 709 | } |
| 710 | } |
| 711 | const ssize_t cut_length = 100; |
| 712 | if (len(message) > 2 * cut_length + 3) { |
| 713 | return str(message[slice(0, cut_length, 1)]) + str("✄✄✄") |
| 714 | + str(message[slice(-cut_length, static_cast<ssize_t>(len(message)), 1)]); |
| 715 | } |
| 716 | return message; |
| 717 | } |
| 718 | |
| 719 | template <typename KeyType> |
| 720 | str format_message_key_error(const KeyType &key) { |
no test coverage detected