Thanks for pointing that out, Jiv. I finally put together my upgraded
desktop that has been sitting on the floor beside my desk for 2 months over
the weekend and the last message I got from my laptop was this one, I think.
Nik, if you don't know what Jiv is talking about, take a look at the Java
class tree (the 1.3 API). You will notice that there are 2 major types of
things that can go wrong when running your code: errors and exceptions.
Errors occur when something goes wrong with the code interacting with the
platform (machine) running your program; exceptions happen because of bad
code, lost files, network interruptions, security violations, etc. You are
not interested (from the code's perspective) in trapping system errors -
there's usually nothing you can do about them (like a stack overflow or bios
crash) and are generally meaningless, even if they are caught before
catastrophe.
Exceptions, on the other hand, are not only valuable because it makes the
compiler and JVM enforce rules prior to compilation which forces you rewrite
(or at least, rethink) your code. There are two types of exceptions:
compile-time and runnable. The compiler forces you to catch compile-time
exceptions (java.lang.Exception and it's subclasses) because it must catch
them, and the compiler forces you to at least declare in your method
signature that a runnable (java.lang.RuntimeException or its subclasses)
exception may be thrown during the execution of the program.
So what Jiv is saying, if you cannot get any more specific about what type
of exception may occur, change your code to:
try {
[whatever]
} catch( Exception e) {
e.printStackTrace(); // or e.getMessage()
}
better would be something more specific, like
try{
Class.forName( "my.sql.Driver");
} catch( ClassNotFoundException e) {
e.printStackTrace();
}
Then take a look at your browser's Java console and see what's happening.
Cheers!
Mark
----- Original Message -----
From: "Kainth, Jivraj" <[EMAIL PROTECTED]>
Sent: Monday, April 23, 2001 3:40 AM
> That should do!
> Why are you catching Throwable? This is bas practice as you will end up
> catching run-time Errors in the VM as well as Exceptions. I would catch
> Exceptions only.
>
> --JIv
>
> -----Original Message-----
> From: Nik DAMPIER [mailto:[EMAIL PROTECTED]]
> Sent: 22 April 2001 13:32
>
>
> Do I print the error message in my throwable object like this?
>
> catch (Throwable e){
> System.out.println(e.getMessage());}
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html