]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/jaegertracing/opentelemetry-cpp/third_party/nlohmann-json/doc/examples/out_of_range.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / third_party / nlohmann-json / doc / examples / out_of_range.cpp
diff --git a/ceph/src/jaegertracing/opentelemetry-cpp/third_party/nlohmann-json/doc/examples/out_of_range.cpp b/ceph/src/jaegertracing/opentelemetry-cpp/third_party/nlohmann-json/doc/examples/out_of_range.cpp
new file mode 100644 (file)
index 0000000..e711640
--- /dev/null
@@ -0,0 +1,20 @@
+#include <iostream>
+#include <nlohmann/json.hpp>
+
+using json = nlohmann::json;
+
+int main()
+{
+    try
+    {
+        // calling at() for an invalid index
+        json j = {1, 2, 3, 4};
+        j.at(4) = 10;
+    }
+    catch (json::out_of_range& e)
+    {
+        // output exception information
+        std::cout << "message: " << e.what() << '\n'
+                  << "exception id: " << e.id << std::endl;
+    }
+}