Don't crash if there are zero valued attributes
[mech_eap.orig] / util_json.h
index 43d3275..e2c5e29 100644 (file)
@@ -49,6 +49,24 @@ using namespace shibsp;
 namespace gss_eap_util {
     class JSONObject;
 
+    class JSONException : public std::exception {
+    public:
+        JSONException(json_t *obj = NULL, json_type type = JSON_NULL);
+
+        ~JSONException(void) throw() {
+            json_decref(m_obj);
+        }
+
+        virtual const char *what(void) const throw() {
+            return m_reason.c_str();
+        }
+
+    private:
+        json_t *m_obj;
+        json_type m_type;
+        std::string m_reason;
+    };
+
     class JSONIterator {
     public:
         JSONIterator(const JSONObject &obj);