Why exception messages suck
One of my pet peeves is that library builders take special care to check for errors or exception conditions, but fail miserably to communicate what is wrong and how to fix it. The case today: json-lib (2.1).
I'm trying to use it to serialize a bean to JSON format and to compare it to a JSON serialized bean (it is easier to check text instead of the debugger trees). But the json-lib tells me that there is a cycle in the bean.
Caused by: net.sf.json.JSONException: There is a cycle in the hierarchy! at net.sf.json.util.CycleDetectionStrategy$StrictCycleDetectionStrategy.handleRepeatedReferenceAsObject(CycleDetectionStrategy.java:73) at net.sf.json.JSONObject._fromBean(JSONObject.java:658) at net.sf.json.JSONObject.fromObject(JSONObject.java:182) at net.sf.json.JSONObject._processValue(JSONObject.java:2426) at net.sf.json.JSONObject._setInternal(JSONObject.java:2447) at net.sf.json.JSONObject.setValue(JSONObject.java:1189) at net.sf.json.JSONObject._fromBean(JSONObject.java:725) at net.sf.json.JSONObject.fromObject(JSONObject.java:182) at net.sf.json.JSONObject._processValue(JSONObject.java:2426) at net.sf.json.JSONObject._setInternal(JSONObject.java:2447) at net.sf.json.JSONObject.setValue(JSONObject.java:1189) at net.sf.json.JSONObject._fromBean(JSONObject.java:725) at net.sf.json.JSONObject.fromObject(JSONObject.java:182) at net.sf.json.JSONObject._processValue(JSONObject.java:2426) at net.sf.json.JSONObject._setInternal(JSONObject.java:2447) at net.sf.json.JSONObject.setValue(JSONObject.java:1189) at net.sf.json.JSONObject._fromBean(JSONObject.java:725) at net.sf.json.JSONObject.fromObject(JSONObject.java:182) at net.sf.json.JSONObject._processValue(JSONObject.java:2426) at net.sf.json.JSONObject._setInternal(JSONObject.java:2447) at net.sf.json.JSONObject.setValue(JSONObject.java:1189) at net.sf.json.JSONObject._fromBean(JSONObject.java:725) at net.sf.json.JSONObject.fromObject(JSONObject.java:182) at net.sf.json.JSONObject.fromObject(JSONObject.java:145)
Very informative stack trace indeed.