Android: How to catch Fatal Exception thrown from link library?

I am using a reference library called 'rome-1.0.jar'.

try { SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(new XmlReader(file)); } catch(Exception e) { Log.e("", "ROME parse error: " + e.toString()); } 

input.build (new XmlReader (file)); this is a call to the library "rome-1.0.jar".

Although I catch all Exceptions, my application still crashes.

 05-31 13:43:06.297: W/dalvikvm(11150): threadid=22: thread exiting with uncaught exception (group=0x40a4d1f8) 05-31 13:43:06.307: E/AndroidRuntime(11150): FATAL EXCEPTION: Thread-4199 05-31 13:43:06.307: E/AndroidRuntime(11150): java.lang.NoClassDefFoundError: java.beans.PropertyDescriptor[] 05-31 13:43:06.307: E/AndroidRuntime(11150): at com.sun.syndication.feed.impl.BeanIntrospector.getPropertyDescriptors(BeanIntrospector.java:39) 05-31 13:43:06.307: E/AndroidRuntime(11150): at com.sun.syndication.feed.impl.CloneableBean.beanClone(CloneableBean.java:129) 05-31 13:43:06.307: E/AndroidRuntime(11150): at com.sun.syndication.feed.impl.ObjectBean.clone(ObjectBean.java:87) 05-31 13:43:06.307: E/AndroidRuntime(11150): at com.sun.syndication.feed.module.DCModuleImpl.clone(DCModuleImpl.java:771) 05-31 13:43:06.307: E/AndroidRuntime(11150): at com.sun.syndication.feed.module.impl.ModuleUtils.cloneModules(ModuleUtils.java:35) 05-31 13:43:06.307: E/AndroidRuntime(11150): at com.sun.syndication.feed.synd.impl.ConverterForRSS090.createSyndEntry(ConverterForRSS090.java:90) 05-31 13:43:06.307: E/AndroidRuntime(11150): at com.sun.syndication.feed.synd.impl.ConverterForRSS091Userland.createSyndEntry(ConverterForRSS091Userland.java:85) 05-31 13:43:06.307: E/AndroidRuntime(11150): at com.sun.syndication.feed.synd.impl.ConverterForRSS092.createSyndEntry(ConverterForRSS092.java:46) 05-31 13:43:06.307: E/AndroidRuntime(11150): at com.sun.syndication.feed.synd.impl.ConverterForRSS093.createSyndEntry(ConverterForRSS093.java:37) 05-31 13:43:06.307: E/AndroidRuntime(11150): at com.sun.syndication.feed.synd.impl.ConverterForRSS094.createSyndEntry(ConverterForRSS094.java:58) 05-31 13:43:06.307: E/AndroidRuntime(11150): at com.sun.syndication.feed.synd.impl.ConverterForRSS090.createSyndEntries(ConverterForRSS090.java:79) 05-31 13:43:06.307: E/AndroidRuntime(11150): at com.sun.syndication.feed.synd.impl.ConverterForRSS090.copyInto(ConverterForRSS090.java:64) 05-31 13:43:06.307: E/AndroidRuntime(11150): at com.sun.syndication.feed.synd.impl.ConverterForRSS091Userland.copyInto(ConverterForRSS091Userland.java:49) 05-31 13:43:06.307: E/AndroidRuntime(11150): at com.sun.syndication.feed.synd.impl.ConverterForRSS094.copyInto(ConverterForRSS094.java:47) 05-31 13:43:06.307: E/AndroidRuntime(11150): at com.sun.syndication.feed.synd.SyndFeedImpl.<init>(SyndFeedImpl.java:144) 05-31 13:43:06.307: E/AndroidRuntime(11150): at com.sun.syndication.io.SyndFeedInput.build(SyndFeedInput.java:123) ...(my code) 

Is there any way to handle this?

+4
source share
2 answers

Thank you, Kumar, you gave me an idea.

I did not know that it was a mistake. I processed OutOfMemoryError before I know that I can handle errors.

 try { SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(new XmlReader(file)); } catch(Exception e) { Log.e("", "ROME parse error: " + e.toString()); } catch(Error e2) { Log.e("", "ROME parse error2: " + e2.toString()); } 

Errors are handled above the code. I know this is not a good idea, but it serves my purpose.

Thanks.

+3
source

This is not an exception, but rather a mistake whose nature is more severe than exceptions. You should not handle errors.

http://www.coderanch.com/t/269746/java-programmer-SCJP/certification/Error-vs-Exception

If errors occur, the system in most cases will become unstable, and you really can not do anything about it.

+2
source

Source: https://habr.com/ru/post/1415431/


All Articles