Extended "Surround with try-catch"
Example:
-
public class HibernateTest extends TestCase {
protected static SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
-
with:
Configuration.configure() throws Exception
Alt+Enter should create the following:
-
public class HibernateTest extends TestCase {
protected static SessionFactory sessionFactory;
static{
try {
sessionFactory = new Configuration().configure().buildSessionFactory();
} catch ( HibernateException e ) {
}
}
-
Please sign in to leave a comment.
That would be promoting bad code. You can't throw exceptions from a static block, but shouldn't ignore it either. In other words, you shouldn't be doing error-prone code in a static initializer.
And if we're talking about the "surround with try/catch" behavior, a nice thing would be ask which exceptions you want to catch, and which you want to declare.
The action would pop a dialog with all the exceptions thrown in the selected block. You could then select which exceptions you want to catch and which you want to declare. IDEA would then generate a try{} ... catch{} block for those you selected to catch, and add to the method signature those you selected to declare.
Ah but there are issues with this as you quite rightly pointed out in
http://www.intellij.net/tracker/idea/viewSCR?publicId=21929 ... don't go
pretending it's all simple now! ;)
Marcus Brito wrote:
Yeah - of course you´r right...
Was typing faster than thinking...
And I was one of the people proposing solutions there. Damn short memory ^^