Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

System.out.println is Wrong??

 
Julio Cesar Marques
Ranch Hand
Posts: 80
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends!

What is a best pratice in my catch blocks? (for dont lost poits)

1) catch (IOException e) {
System.out.println(......);
}

2) catch (IOException e) {
JOptionPane.message(......);
}

3) catch (IOException e) {
logger.log(ERROR, ....)
}

4) they don't care

Many thanks
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fala ai Julio!!

In my opinion, it really depends on where you are. For instance, if you are in the business/services layer and an exception from a lower layer occurred there, you can log this exception and rethrow an exception that belongs to the business/services layer, with the lower level exception encapsulated in it. If you are in the last layer (for instance, the view layer), then you can log it and call JOptionPane.showMessageDialog, with JOptionPane.ERROR_MESSAGE.
 
Julio Cesar Marques
Ranch Hand
Posts: 80
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Grande Bob!!

So it's sounds good to me but to be honest i'm with a little lazy to do like this and i had hope you say "yeah put system.out in everyplaces and go on!" lol. But.... if i can do, i can do...

Best Regards!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic