The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

Java style question. by dodrian2007-03-04 09:37:08
  Throw an exception. by williamashbless 2007-03-04 09:48:55
Of your own. It may still exit if left unhandled, but at least you provide the opportunity for some bit of code to catch the exception and do some sort of intelligent handling instead of just bailing out.

First check to see if there's a Java exception class already created that suits the meaning of the error. Use that. If not, create your own exception class derived from one of the main Java exception base classes (Exception vs RuntimeException for example).

Google for "Java exception handling", and Sun has tutorials on all this stuff.

Me, I'm not big on exception handling, but my upbringing in coding made me use error codes. But Java's bigger on exception handling for serious 'error cases', so there's my recommendation. Either way, you should handle your errors in a way that enable the user of your code to cope with the problem.

Unless the problem can't be coped with.

Or you don't want to let them cope with it.

But that's a judgment call.

:D
[ Reply ]
    What he said. by aix tom2007-03-04 09:59:54
    Caveat! by SoylentGreen2007-03-04 12:11:09

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)