• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

System.out.println is Wrong??

 
Ranch Hand
Posts: 80
BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
reply
    Bookmark Topic Watch Topic
  • New Topic