! @param[in] format the current format @param[in] detail a detailed error message @param[in] context further context information @return a message string to use in the parse_error exceptions */
| 11986 | @return a message string to use in the parse_error exceptions |
| 11987 | */ |
| 11988 | std::string exception_message(const input_format_t format, |
| 11989 | const std::string& detail, |
| 11990 | const std::string& context) const |
| 11991 | { |
| 11992 | std::string error_msg = "syntax error while parsing "; |
| 11993 | |
| 11994 | switch (format) |
| 11995 | { |
| 11996 | case input_format_t::cbor: |
| 11997 | error_msg += "CBOR"; |
| 11998 | break; |
| 11999 | |
| 12000 | case input_format_t::msgpack: |
| 12001 | error_msg += "MessagePack"; |
| 12002 | break; |
| 12003 | |
| 12004 | case input_format_t::ubjson: |
| 12005 | error_msg += "UBJSON"; |
| 12006 | break; |
| 12007 | |
| 12008 | case input_format_t::bson: |
| 12009 | error_msg += "BSON"; |
| 12010 | break; |
| 12011 | |
| 12012 | case input_format_t::bjdata: |
| 12013 | error_msg += "BJData"; |
| 12014 | break; |
| 12015 | |
| 12016 | case input_format_t::json: // LCOV_EXCL_LINE |
| 12017 | default: // LCOV_EXCL_LINE |
| 12018 | JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE |
| 12019 | } |
| 12020 | |
| 12021 | return concat(error_msg, ' ', context, ": ", detail); |
| 12022 | } |
| 12023 | |
| 12024 | private: |
| 12025 | static JSON_INLINE_VARIABLE constexpr std::size_t npos = static_cast<std::size_t>(-1); |