greptilian logo

IRC log for #friendlyjava, 2014-08-08

##friendlyjava on freenode

| Channels | #friendlyjava index | Today | | Search | Google Search | Plain-Text | plain, newest first | summary

All times shown according to UTC.

Time S Nick Message
18:18 aditsu joined ##friendlyjava
18:48 pdurbin any ideas for me? http://irclog.greptilian.com/sourcefu/2014-08-08#i_72688
19:07 * aditsu hates checked exceptions
19:21 pdurbin sure
19:21 pdurbin but the unchecked exception should be caught
19:32 pdurbin really the question is about tooling
19:48 aditsu pdurbin: so you want others to catch your exceptions? or you want to catch the exceptions thrown by others?
19:49 pdurbin I don't want to be suprised by a RuntimeException when I expect a null instead
19:53 pdurbin does that make sense?
20:02 aditsu then you can just catch all
20:04 pdurbin well, I have to catch the EJBTransactionRolledbackException
20:04 pdurbin then if (ex.getCause() instanceof TransactionRolledbackLocalException)
20:05 pdurbin then I can see what the exception was
20:05 pdurbin if (ex.getCause().getCause() instanceof NoResultException)
20:05 aditsu o_O
20:06 pdurbin https://github.com/IQSS/dataverse/blob/master/src/main/java/edu/harvard/iq/dataverse/SearchServiceBean.java#L288
20:06 aditsu please, I just had lunch
20:07 pdurbin heh
20:07 aditsu you're doing all those checks just to log something?
20:08 pdurbin heh
20:08 pdurbin well
20:09 pdurbin I was surprised when it blew up on me
20:09 pdurbin I expected null
20:10 aditsu isn't there a method that returns null instead?
20:10 aditsu if not, maybe you should use something with a better api :p
20:11 pdurbin ah ha
20:11 pdurbin someone wrote a "does not throw exceptions" version: https://github.com/IQSS/dataverse/blob/master/src/main/java/edu/harvard/iq/dataverse/DatasetFieldServiceBean.java#L59
20:12 aditsu alright :)
20:13 aditsu btw, java 8 has an Optional type
20:14 pdurbin hmm
20:59 pdurbin anyway, it's all good. I'm just trying to figure out some best practices
22:57 pdurbin aditsu: oh and it's *not* just to log something
22:58 pdurbin if you don't catch a RuntimeException it becomes an EJBException and your whole app breaks
22:58 pdurbin the page, your api call, anything
22:58 pdurbin broken
22:58 pdurbin so you have to look out for RuntimeExceptions in Java EE
23:55 aditsu pdurbin: but you just need to catch it, you don't have to check the cause of the cause of the cause

| Channels | #friendlyjava index | Today | | Search | Google Search | Plain-Text | plain, newest first | summary

##friendlyjava on freenode