Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Customize ouput of automatic try/catch
Customize ouput of automatic try/catch [message #214759] Sat, 09 June 2007 18:25 Go to next message
No real name is currently offline No real nameFriend
Messages: 38
Registered: July 2009
Member
For the Java auto-correction feature of adding a try/catch, is there any way
to customize what is output, including the following:

- name of the exception parameter
- comments, or lack thereof (I'd like to get rid of the automatic TODO
added)
- any other standard code, such as adding in myCustomLogMethod(exception)

Where would I customize these?

Thanks?
Re: Customize ouput of automatic try/catch [message #214767 is a reply to message #214759] Sat, 09 June 2007 20:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: news.pellaton.li

Hi

- Go to Window > Preferences > Java > Code Style > Code Templates
- Then in list on the right pane select for the item "Catch Block Body"
- Click on [Edit...]
- change the block's template to your linking

--> look at the variables - they might help you write less code ;-)

Michael
Re: Customize ouput of automatic try/catch [message #732356 is a reply to message #214767] Tue, 04 October 2011 15:08 Go to previous message
Ana  is currently offline Ana Friend
Messages: 1
Registered: October 2011
Junior Member
Hello! I have a similiar question.
After surrounding with try/catch first line of code like...
String s = new String("value");
System.out.println(s);


...I get...
String s;
try {
	s = new String("value");
} catch (Exception e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}
System.out.println(s);


.. and the exception in the last line, pointing that the variable 's' may not have been initialized.

How can I edit the default template so that it automatically assignt value of null to the variable?

Thanks in advance.
Previous Topic:Installation problem
Next Topic:Calling fortran function from c
Goto Forum:
  


Current Time: Tue Mar 19 05:23:48 GMT 2024

Powered by FUDForum. Page generated in 0.03420 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top