|
|
Back to UserFriendly Strip Comments Index
|
Java style question. | by dodrian | 2007-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 tom | 2007-03-04 09:59:54 |
|
Caveat! | by SoylentGreen | 2007-03-04 12:11:09 |
|
|
[Todays Cartoon Discussion]
[News Index]
|
|