There is an error because a "throw" gets you out of the method (function) ,
so "return" is never reached.
Also "Exception" is the mother of all exceptions. You throw that, you need
not specify that you are throwing an IOException. The compiler is smart
enough to figure that out.

Cheers,
Amar..





Jere Robinson <[EMAIL PROTECTED]> on 03/30/99 05:02:20 PM

Please respond to "A mailing list for discussion about Sun Microsystem's
      Java              Servlet API Technology."
      <[EMAIL PROTECTED]>

To:   [EMAIL PROTECTED]
cc:    (bcc: Amarnath Nanduri/IT/VANCPOWER)
Subject:  Re: Throwing Exceptions problem. (fwd)




I think I found it.  I needed to throw new Exception(error); and get rid
of the return;s.  Now I know where the error is!  Weeeeee... have no
idea why there is an error, but I know where it is...

Jere

On Tue, 30 Mar 1999, Jere Robinson wrote:

> Hey guys, I'm trying to add a little bit of error detection and recovery
> to the coolservlets SmtpEmail class.  When the class writes to the port,
I
> try to catch the response, and if it's not what is expected, throw an
> exception and close out of the function.  The trouble is, I throw
> Exception(String) and javac replies that 'Exception' is not found in
> SmtpEmail (compile time error).
>
> huh?  Here is some code.. don't pick.. I'm at the start of my little java
> code life.
>
>
> public void send( )
>      throws Exception, IOException
>  {
>  yadda yadda..
>
>  if(errant("2",in))
>    {
>    error = "There was a problem with the RCPT TO response.";
>    out.println( "QUIT" );
>    out.close();
>    throw Exception(error);
>    return;
>    }
>
>  ..yadda yadda
>  }
>
> The plan is to find out why this very nice package acts like it sent the
> mail, but then doesn't.
>
> Another compile time error is that all my returns
> are unreachable.. does throwing an exception kill the function that threw
> it?
>
> You can tell I'm a C++ student, can't you?
>
> Thanks,
> Jere
>
>
___________________________________________________________________________
> 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
>

___________________________________________________________________________
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

___________________________________________________________________________
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

Reply via email to