I'd like to use Simple XML to help parse requests to one of my API's I'm adding to a webapp. I'd like better programmatic access to specific attributes, elements, etc. that actually cause a validation error. While the current exceptions are helpful for me, they aren't useful to display to a caller of my API. They aren't in a format that would be helpful to display to a caller of my API. I'm probably going to have to resort to some sort of String extraction to properly display them as an error message.
What I'd like is extended properties added to each type of Exception that Simple XML can throw. For example, this is an a typical error thrown by your API:
Exception in thread "main" org.simpleframework.xml.core.ValueRequiredException: Unable to satisfy @org.simpleframework.xml.Attribute(name=, empty=, required=true) on field 'name' for class net.cloudhopper.simplexml.demo.Person at line 1
What I'd actually prefer is that you add properties to the ValueRequiredException class that let me programmatically access the errors. For example, you'd add "getLine()" and "getAttributeName" or maybe just "getName()", etc. That would help me build me own error message I'd display to a caller of my API. If I'm parsing only a snippet of XML within a larger document, I could access getLineNumber() and add it to the line number I know I'm on.
You could add similar properties to every exception you currently throw. This would be immensely helpful to me and probably other users!
Finally, I'm wondering why you generically throw an "Exception" in your Serializer object? Why don't you at least throw PersistenceException? Maybe that could be changed in a future version? I doubt it would break any backwards compatibility if most folks are already generically catching Exception.