PropertyListParser.parse throws Exception

36 views
Skip to first unread message

boxie ncosi

unread,
Dec 20, 2013, 5:37:11 AM12/20/13
to plist-...@googlegroups.com
Hi, 

First of all thanks for the library, it is useful.

I see that com.dd.plist.PropertyListParser.parse(InputStream) throws Exception
I'm curious about the reasoning behind it.
Can you explain a little bit?

I'm asking because, I would like to surround my code using PropertyListParser.parse with a try catch block catching more specific exceptions, e.g., IOException,  PropertyListParserException



Cheers

Daniel Dreibrodt

unread,
Dec 20, 2013, 6:57:04 AM12/20/13
to plist-discuss
Hi,

i throw some custom Exceptions, e.g. when the property list data is invalid or not enough heap space is available. I did not bother to create custom Exceptions for those cases or use appropriate, existing Exception classes. Maybe that was a bit of negligence on my part.

But do you really need custom Exceptions to handle the different kind of errors that could occur during parsing? Would your error handling react differently to the different exceptions?

Maybe in some future version I could remove all uses of "throws Exception" and be more specific. But I have no time plan as to when I continue work on the library.

Regards

--
You received this message because you are subscribed to the Google Groups "plist-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to plist-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

boxie ncosi

unread,
Dec 23, 2013, 11:19:17 PM12/23/13
to plist-...@googlegroups.com
Having more specific exceptions would be very nice.

Yes, the code would react differently to different exceptions, e.g., reacting to an exception thrown by com.dd.plist.PropertyListParser.parse  would show "Invalid property file", whereas the reaction to FileNotFoundException would show something like "The file can't be accessed".


completely understand the time constraints. 


Regards


Daniel Dreibrodt

unread,
Dec 24, 2013, 3:36:25 AM12/24/13
to plist-discuss
I think you can already now react to the different exceptions. Although the method is declared to throw general exceptions, internally also FileNotFoundException and other IOExceptions can be caught. All other exceptions would refer either to a broken property list or not enough heap space. In the future i can differentiate the exceptions further.

If you put the catch block for these specific exceptions before the catch block for general exception I think the specific exceptions would be caught properly.

Regards


Reply all
Reply to author
Forward
0 new messages