You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by Susantha Kumara <su...@opensource.lk> on 2004/06/24 08:20:50 UTC

Exception handling - trivial try catch blocks

Hi all,
 
I see that in Axis code there are trivial try.catch blocks (in
approximately 50 places) like following,
 
    try {
     ....
     ....
    }
    catch(AxisTransportException& e)
    {
        throw;
    }
    catch(AxisException& e)
    {
        throw;
    }
    catch(...)
    {
        throw;
    }
 
This kind of code avoids compiler errors in Java. But in C++ this has no
effect other than increasing the size of code.
Please correct me if I am wrong.
 
Do we have any plans to do something with the catched exception other
than re-throwing it ?. If so we need this blocks. If not I suggest that
we remove them safely.
 
Thanks,
 
Susantha Kumara
 

Re: Exception handling - trivial try catch blocks

Posted by John Hawkins <HA...@uk.ibm.com>.



Sounds good to me

John Hawkins




                                                                           
             "Sanjiva                                                      
             Weerawarana"                                                  
             <sanjiva@opensour                                          To 
             ce.lk>                    "Apache AXIS C Developers List"     
                                       <ax...@ws.apache.org>          
             29/06/2004 10:19                                           cc 
                                                                           
                                                                   Subject 
             Please respond to         Re: Exception handling - trivial    
              "Apache AXIS C           try catch blocks                    
             Developers List"                                              
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




If there's a catch and a re-throw of an exception it may be useful to do
what's
done in Java: constructor the new exception with the old one referenced in
it. (Look at the "targetException" field of java.lang.Exception for
example.)

That way all the "old" info is there and the catcher can add additional
info.

Sanjiva.

----- Original Message -----
From: "damitha kumarage" <da...@opensource.lk>
To: "Apache AXIS C Developers List" <ax...@ws.apache.org>
Sent: Tuesday, June 29, 2004 12:34 PM
Subject: Re: Exception handling - trivial try catch blocks


> On Thu, 2004-06-24 at 13:52, John Hawkins wrote:
> >
> >
> > If, when throwing the exception (A new exception?) we add more specific
> > information about the originally caught exception then this is worth
doing.
> Yes we need to let the new thrower to append a message to the exception
> he caught.
>
> > If we simply throw a new exception with no new information specific to
the
> > catch then these can probably be removed?
> yes
> >
> > However, if we are not using the information gained from the specific
> > exception then we are missing a trick. The key point is that when the
> > exception finally gets to the application it needs as much information
as
> > possible about the original exception to enable the application to
> > determine what to do next.
> yes
>
> thanks
> damitha
> >
> >
> > John Hawkins
> >
> >
> >
> >
> >
> >              damitha kumarage
> >              <damitha@opensour
> >              ce.lk>
To
> >                                        Apache AXIS C Developers List
> >              24/06/2004 08:34          <ax...@ws.apache.org>
> >
cc
> >
> >              Please respond to
Subject
> >               "Apache AXIS C           Re: Exception handling - trivial
> >              Developers List"          try catch blocks
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Thu, 2004-06-24 at 12:20, Susantha Kumara wrote:
> > > Hi all,
> > >
> > >
> > >
> > > I see that in Axis code there are trivial try…catch blocks (in
> > > approximately 50 places) like following,
> > >
> > >
> > >
> > >     try {
> > >
> > >     ……..
> > >
> > >     ……..
> > >
> > >     }
> > >
> > >     catch(AxisTransportException& e)
> > >
> > >     {
> > >
> > >         throw;
> > >
> > >     }
> > >
> > >     catch(AxisException& e)
> > >
> > >     {
> > >
> > >         throw;
> > >
> > >     }
> > >
> > >     catch(...)
> > >
> > >     {
> > >
> > >         throw;
> > >
> > >     }
> > >
> > >
> > >
> > > This kind of code avoids compiler errors in Java. But in C++ this has
> > > no effect other than increasing the size of code.
> > >
> > > Please correct me if I am wrong.
> > >
> > >
> > >
> > > Do we have any plans to do something with the catched exception other
> > > than re-throwing it ?. If so we need this blocks. If not I suggest
> > > that we remove them safely.
> >
> > Does it affect the performance if we keep them?. In java it is advised
> > to avoid unneccessary try blocks. So I guess it is same with C++.
> > I put them while adding exception handling capabilities to the code
> > and guessed that responsible developer might have something to do
> > with the exceptions caught.
> > OK, if it's a problems let's remove them and let the developer
> > add it if neccessary.
> >
> > thanks
> > damitha
> > >
> >
>
>


Re: Exception handling - trivial try catch blocks

Posted by Sanjiva Weerawarana <sa...@opensource.lk>.
If there's a catch and a re-throw of an exception it may be useful to do
what's
done in Java: constructor the new exception with the old one referenced in
it. (Look at the "targetException" field of java.lang.Exception for
example.)

That way all the "old" info is there and the catcher can add additional
info.

Sanjiva.

----- Original Message ----- 
From: "damitha kumarage" <da...@opensource.lk>
To: "Apache AXIS C Developers List" <ax...@ws.apache.org>
Sent: Tuesday, June 29, 2004 12:34 PM
Subject: Re: Exception handling - trivial try catch blocks


> On Thu, 2004-06-24 at 13:52, John Hawkins wrote:
> >
> >
> > If, when throwing the exception (A new exception?) we add more specific
> > information about the originally caught exception then this is worth
doing.
> Yes we need to let the new thrower to append a message to the exception
> he caught.
>
> > If we simply throw a new exception with no new information specific to
the
> > catch then these can probably be removed?
> yes
> >
> > However, if we are not using the information gained from the specific
> > exception then we are missing a trick. The key point is that when the
> > exception finally gets to the application it needs as much information
as
> > possible about the original exception to enable the application to
> > determine what to do next.
> yes
>
> thanks
> damitha
> >
> >
> > John Hawkins
> >
> >
> >
> >
> >
> >              damitha kumarage
> >              <damitha@opensour
> >              ce.lk>
To
> >                                        Apache AXIS C Developers List
> >              24/06/2004 08:34          <ax...@ws.apache.org>
> >
cc
> >
> >              Please respond to
Subject
> >               "Apache AXIS C           Re: Exception handling - trivial
> >              Developers List"          try catch blocks
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Thu, 2004-06-24 at 12:20, Susantha Kumara wrote:
> > > Hi all,
> > >
> > >
> > >
> > > I see that in Axis code there are trivial try…catch blocks (in
> > > approximately 50 places) like following,
> > >
> > >
> > >
> > >     try {
> > >
> > >     ……..
> > >
> > >     ……..
> > >
> > >     }
> > >
> > >     catch(AxisTransportException& e)
> > >
> > >     {
> > >
> > >         throw;
> > >
> > >     }
> > >
> > >     catch(AxisException& e)
> > >
> > >     {
> > >
> > >         throw;
> > >
> > >     }
> > >
> > >     catch(...)
> > >
> > >     {
> > >
> > >         throw;
> > >
> > >     }
> > >
> > >
> > >
> > > This kind of code avoids compiler errors in Java. But in C++ this has
> > > no effect other than increasing the size of code.
> > >
> > > Please correct me if I am wrong.
> > >
> > >
> > >
> > > Do we have any plans to do something with the catched exception other
> > > than re-throwing it ?. If so we need this blocks. If not I suggest
> > > that we remove them safely.
> >
> > Does it affect the performance if we keep them?. In java it is advised
> > to avoid unneccessary try blocks. So I guess it is same with C++.
> > I put them while adding exception handling capabilities to the code
> > and guessed that responsible developer might have something to do
> > with the exceptions caught.
> > OK, if it's a problems let's remove them and let the developer
> > add it if neccessary.
> >
> > thanks
> > damitha
> > >
> >
>
>


Re: Exception handling - trivial try catch blocks

Posted by damitha kumarage <da...@opensource.lk>.
On Thu, 2004-06-24 at 13:52, John Hawkins wrote:
> 
> 
> If, when throwing the exception (A new exception?) we add more specific
> information about the originally caught exception then this is worth doing.
Yes we need to let the new thrower to append a message to the exception
he caught.

> If we simply throw a new exception with no new information specific to the
> catch then these can probably be removed?
yes
> 
> However, if we are not using the information gained from the specific
> exception then we are missing a trick. The key point is that when the
> exception finally gets to the application it needs as much information as
> possible about the original exception to enable the application to
> determine what to do next.
yes

thanks
damitha
> 
> 
> John Hawkins
> 
> 
> 
> 
>                                                                            
>              damitha kumarage                                              
>              <damitha@opensour                                             
>              ce.lk>                                                     To 
>                                        Apache AXIS C Developers List       
>              24/06/2004 08:34          <ax...@ws.apache.org>          
>                                                                         cc 
>                                                                            
>              Please respond to                                     Subject 
>               "Apache AXIS C           Re: Exception handling - trivial    
>              Developers List"          try catch blocks                    
>                                                                            
>                                                                            
>                                                                            
>                                                                            
>                                                                            
>                                                                            
> 
> 
> 
> 
> On Thu, 2004-06-24 at 12:20, Susantha Kumara wrote:
> > Hi all,
> >
> >
> >
> > I see that in Axis code there are trivial try…catch blocks (in
> > approximately 50 places) like following,
> >
> >
> >
> >     try {
> >
> >     ……..
> >
> >     ……..
> >
> >     }
> >
> >     catch(AxisTransportException& e)
> >
> >     {
> >
> >         throw;
> >
> >     }
> >
> >     catch(AxisException& e)
> >
> >     {
> >
> >         throw;
> >
> >     }
> >
> >     catch(...)
> >
> >     {
> >
> >         throw;
> >
> >     }
> >
> >
> >
> > This kind of code avoids compiler errors in Java. But in C++ this has
> > no effect other than increasing the size of code.
> >
> > Please correct me if I am wrong.
> >
> >
> >
> > Do we have any plans to do something with the catched exception other
> > than re-throwing it ?. If so we need this blocks. If not I suggest
> > that we remove them safely.
> 
> Does it affect the performance if we keep them?. In java it is advised
> to avoid unneccessary try blocks. So I guess it is same with C++.
> I put them while adding exception handling capabilities to the code
> and guessed that responsible developer might have something to do
> with the exceptions caught.
> OK, if it's a problems let's remove them and let the developer
> add it if neccessary.
> 
> thanks
> damitha
> >
> 


Re: Exception handling - trivial try catch blocks

Posted by John Hawkins <HA...@uk.ibm.com>.



If, when throwing the exception (A new exception?) we add more specific
information about the originally caught exception then this is worth doing.
If we simply throw a new exception with no new information specific to the
catch then these can probably be removed?

However, if we are not using the information gained from the specific
exception then we are missing a trick. The key point is that when the
exception finally gets to the application it needs as much information as
possible about the original exception to enable the application to
determine what to do next.


John Hawkins




                                                                           
             damitha kumarage                                              
             <damitha@opensour                                             
             ce.lk>                                                     To 
                                       Apache AXIS C Developers List       
             24/06/2004 08:34          <ax...@ws.apache.org>          
                                                                        cc 
                                                                           
             Please respond to                                     Subject 
              "Apache AXIS C           Re: Exception handling - trivial    
             Developers List"          try catch blocks                    
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




On Thu, 2004-06-24 at 12:20, Susantha Kumara wrote:
> Hi all,
>
>
>
> I see that in Axis code there are trivial try…catch blocks (in
> approximately 50 places) like following,
>
>
>
>     try {
>
>     ……..
>
>     ……..
>
>     }
>
>     catch(AxisTransportException& e)
>
>     {
>
>         throw;
>
>     }
>
>     catch(AxisException& e)
>
>     {
>
>         throw;
>
>     }
>
>     catch(...)
>
>     {
>
>         throw;
>
>     }
>
>
>
> This kind of code avoids compiler errors in Java. But in C++ this has
> no effect other than increasing the size of code.
>
> Please correct me if I am wrong.
>
>
>
> Do we have any plans to do something with the catched exception other
> than re-throwing it ?. If so we need this blocks. If not I suggest
> that we remove them safely.

Does it affect the performance if we keep them?. In java it is advised
to avoid unneccessary try blocks. So I guess it is same with C++.
I put them while adding exception handling capabilities to the code
and guessed that responsible developer might have something to do
with the exceptions caught.
OK, if it's a problems let's remove them and let the developer
add it if neccessary.

thanks
damitha
>


Re: Exception handling - trivial try catch blocks

Posted by damitha kumarage <da...@opensource.lk>.
On Thu, 2004-06-24 at 12:20, Susantha Kumara wrote:
> Hi all,
> 
>  
> 
> I see that in Axis code there are trivial try…catch blocks (in
> approximately 50 places) like following,
> 
>  
> 
>     try {
> 
>     ……..
> 
>     ……..
> 
>     }
> 
>     catch(AxisTransportException& e)
> 
>     {
> 
>         throw;
> 
>     }
> 
>     catch(AxisException& e)
> 
>     {
> 
>         throw;
> 
>     }
> 
>     catch(...)
> 
>     {
> 
>         throw;
> 
>     }
> 
>  
> 
> This kind of code avoids compiler errors in Java. But in C++ this has
> no effect other than increasing the size of code.
> 
> Please correct me if I am wrong.
> 
>  
> 
> Do we have any plans to do something with the catched exception other
> than re-throwing it ?. If so we need this blocks. If not I suggest
> that we remove them safely.

Does it affect the performance if we keep them?. In java it is advised
to avoid unneccessary try blocks. So I guess it is same with C++.
I put them while adding exception handling capabilities to the code
and guessed that responsible developer might have something to do
with the exceptions caught.
OK, if it's a problems let's remove them and let the developer
add it if neccessary.

thanks
damitha
>