Click here to Skip to main content
15,890,947 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: SMPT mail problem Pin
bryce12-Jan-04 16:45
bryce12-Jan-04 16:45 
GeneralRe: SMPT mail problem Pin
murali_utr12-Jan-04 17:38
murali_utr12-Jan-04 17:38 
Generalabout cov and eig Pin
Vincent Sim12-Jan-04 10:36
Vincent Sim12-Jan-04 10:36 
GeneralDrag and drop CtreeView Pin
act_x12-Jan-04 10:25
act_x12-Jan-04 10:25 
GeneralRe: Drag and drop CtreeView Pin
KaЯl12-Jan-04 23:54
KaЯl12-Jan-04 23:54 
GeneralCRichedit control scrolling Pin
Anonymous12-Jan-04 10:21
Anonymous12-Jan-04 10:21 
GeneralDarkside mini SQL errors in http extension dll Pin
Kuniva12-Jan-04 10:21
Kuniva12-Jan-04 10:21 
GeneralModifying exceptions inside a catch block Pin
Marcello12-Jan-04 10:09
Marcello12-Jan-04 10:09 
Hello,

Here is the question:
Is it possible to modify an exception inside a catch block and then rethrow it ?

Under
http://www.codeproject.com/cpp/ANSI-cpp-dec96/except.asp
the only point I see connected to this question is:
19When the handler declares a non-constant object, any changes to that
object will not affect the temporary object that was initialized by
execution of the throw-expression. When the handler declares a refer-
ence to a non-constant object, any changes to the referenced object
are changes to the temporary object initialized when the throw-expres-
sion was executed and will have effect should that object be rethrown.

But this is confusing to me because it seems that is possible to modify a
const exception while it is not possible to modify a non const exception:
which is exactly the contrary that I would expect !
like:
<br />
 catch ( BasicException& e ) {<br />
  e.setMessage( e->getMessage() + " some more informations here " ); //not ok<br />
  throw; // rethrow the same exception<br />
 }<br />
<br />
 catch ( const BasicException& e ) {<br />
  e.setMessage( e->getMessage() + " some more informations here " ); // ok<br />
  throw; // rethrow the same exception<br />
 }


Thank you in advance for any answer
Marcello

P.S.
If it is not clear enough what I need to do, here is an example:

<br />
typedef std::basic_string<VCFChar> String;<br />
<br />
class BasicException : public std::exception {<br />
 public:<br />
 BasicException( const VCF::String & message ) {<br />
  message_ = message;<br />
 }<br />
<br />
 void setMessage( const VCF::String & message ) {<br />
  message_ = message;<br />
 }<br />
 String getMessage () {<br />
  return message_;<br />
 }<br />
 String message_;<br />
}<br />
<br />
<br />
class A {<br />
void f() {<br />
 bool error = true;<br />
 if ( error ) {<br />
  throw BasicException( "original message" );<br />
 }<br />
}<br />
<br />
void g() {<br />
 try {<br />
  f();<br />
 }<br />
  catch ( BasicException& e ) {<br />
  e.setMessage( e->getMessage() + " some more informations here " );<br />
  throw; // rethrow the same exception<br />
 }<br />
};<br />
<br />
int main(int argc, char *argv[])<br />
{<br />
  A a;<br />
    try {<br />
   a.g();<br />
    }<br />
    catch ( BasicException& e ) {<br />
        cout << e.getMessage() << endl;<br />
    }<br />
}<br />

GeneralRe: Modifying exceptions inside a catch block Pin
Joaquín M López Muñoz12-Jan-04 11:18
Joaquín M López Muñoz12-Jan-04 11:18 
GeneralRe: Modifying exceptions inside a catch block Pin
Marcello12-Jan-04 17:05
Marcello12-Jan-04 17:05 
Generalunresolved external symbol Pin
TolTol12-Jan-04 9:32
TolTol12-Jan-04 9:32 
GeneralRe: unresolved external symbol Pin
Jörgen Sigvardsson12-Jan-04 9:53
Jörgen Sigvardsson12-Jan-04 9:53 
GeneralRe: unresolved external symbol Pin
TolTol12-Jan-04 11:50
TolTol12-Jan-04 11:50 
QuestionIs there a way to detect a debug build? Pin
toddbrooks12-Jan-04 9:04
toddbrooks12-Jan-04 9:04 
AnswerRe: Is there a way to detect a debug build? Pin
Neville Franks12-Jan-04 9:35
Neville Franks12-Jan-04 9:35 
AnswerRe: Is there a way to detect a debug build? Pin
LizardWiz12-Jan-04 11:25
LizardWiz12-Jan-04 11:25 
GeneralRe: Is there a way to detect a debug build? Pin
toddbrooks12-Jan-04 11:31
toddbrooks12-Jan-04 11:31 
GeneralProblem Deleting Pointer Pin
DruOfGov12-Jan-04 8:18
DruOfGov12-Jan-04 8:18 
GeneralRe: Problem Deleting Pointer Pin
Joe Woodbury12-Jan-04 8:33
professionalJoe Woodbury12-Jan-04 8:33 
GeneralRe: Problem Deleting Pointer Pin
DruOfGov12-Jan-04 8:51
DruOfGov12-Jan-04 8:51 
GeneralRe: Problem Deleting Pointer Pin
Joe Woodbury12-Jan-04 10:02
professionalJoe Woodbury12-Jan-04 10:02 
GeneralRe: Problem Deleting Pointer Pin
DruOfGov12-Jan-04 10:14
DruOfGov12-Jan-04 10:14 
GeneralRe: Problem Deleting Pointer Pin
Joe Woodbury12-Jan-04 10:34
professionalJoe Woodbury12-Jan-04 10:34 
GeneralRe: Problem Deleting Pointer Pin
DruOfGov12-Jan-04 10:38
DruOfGov12-Jan-04 10:38 
GeneralRe: Problem Deleting Pointer Pin
DruOfGov12-Jan-04 10:41
DruOfGov12-Jan-04 10:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.