MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / exception

Class exception

examples/server/json.hpp:4300–4394  ·  view source on GitHub ↗

@brief general exception of the @ref basic_json class @sa https://json.nlohmann.me/api/basic_json/exception/

Source from the content-addressed store, hash-verified

4298/// @brief general exception of the @ref basic_json class
4299/// @sa https://json.nlohmann.me/api/basic_json/exception/
4300class exception : public std::exception
4301{
4302 public:
4303 /// returns the explanatory string
4304 const char* what() const noexcept override
4305 {
4306 return m.what();
4307 }
4308
4309 /// the id of the exception
4310 const int id; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes)
4311
4312 protected:
4313 JSON_HEDLEY_NON_NULL(3)
4314 exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} // NOLINT(bugprone-throw-keyword-missing)
4315
4316 static std::string name(const std::string& ename, int id_)
4317 {
4318 return concat("[json.exception.", ename, '.', std::to_string(id_), "] ");
4319 }
4320
4321 static std::string diagnostics(std::nullptr_t /*leaf_element*/)
4322 {
4323 return "";
4324 }
4325
4326 template<typename BasicJsonType>
4327 static std::string diagnostics(const BasicJsonType* leaf_element)
4328 {
4329#if JSON_DIAGNOSTICS
4330 std::vector<std::string> tokens;
4331 for (const auto* current = leaf_element; current != nullptr && current->m_parent != nullptr; current = current->m_parent)
4332 {
4333 switch (current->m_parent->type())
4334 {
4335 case value_t::array:
4336 {
4337 for (std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i)
4338 {
4339 if (&current->m_parent->m_value.array->operator[](i) == current)
4340 {
4341 tokens.emplace_back(std::to_string(i));
4342 break;
4343 }
4344 }
4345 break;
4346 }
4347
4348 case value_t::object:
4349 {
4350 for (const auto& element : *current->m_parent->m_value.object)
4351 {
4352 if (&element.second == current)
4353 {
4354 tokens.emplace_back(element.first.c_str());
4355 break;
4356 }
4357 }

Callers 5

TESTFunction · 0.85
operator=Method · 0.85
TESTFunction · 0.85
im2col_sycl_f16Function · 0.85
gpt_params_parse_exFunction · 0.85

Calls

no outgoing calls

Tested by 3

TESTFunction · 0.68
operator=Method · 0.68
TESTFunction · 0.68