catch( ... )

B

Bit byte

This is a repost - original message does not seem to have showed up on
this ng after over 4 hours of posting.


Is there any way of retrievieng error information (say, from a 'global'
or system wide) error object - when you are in a catch all statement block?

Sometimes it cannot be helped, when something quirky happens and errors
are propagated up the stack - all the way to the 'one size fits all'
catch (...) statement. It would be useful if there is a way of finding
what srewy thing happened and led us to that point.
 
B

Bit byte

Bit said:
This is a repost - original message does not seem to have showed up on
this ng after over 4 hours of posting.


Is there any way of retrievieng error information (say, from a 'global'
or system wide) error object - when you are in a catch all statement block?

Sometimes it cannot be helped, when something quirky happens and errors
are propagated up the stack - all the way to the 'one size fits all'
catch (...) statement. It would be useful if there is a way of finding
what srewy thing happened and led us to that point.

This should help explain the above a bit more:

void X::foo( const int a, const char*p) {
try {
....
throw new MyException("Blah, blah, blah") ...
....
}
catch( MyException& e) {
cout << "Err message : " << e.info() ;
}
catch ( ... ) {
cout << "I have no idea how we ended here !" ; //Need info here
}
};
 
I

Ian Collins

Bit said:
This is a repost - original message does not seem to have showed up on
this ng after over 4 hours of posting.


Is there any way of retrievieng error information (say, from a 'global'
or system wide) error object - when you are in a catch all statement block?

Sometimes it cannot be helped, when something quirky happens and errors
are propagated up the stack - all the way to the 'one size fits all'
catch (...) statement. It would be useful if there is a way of finding
what srewy thing happened and led us to that point.
Your original post was answered over 7 hours ago, maybe your news server
requires a kick?
 
A

AnonMail2005

Bit said:
This should help explain the above a bit more:

void X::foo( const int a, const char*p) {
try {
....
throw new MyException("Blah, blah, blah") ...
....
}
catch( MyException& e) {
cout << "Err message : " << e.info() ;
}
catch ( ... ) {
cout << "I have no idea how we ended here !" ; //Need info here
}
};
Any library you use should specify the exceptions that it throws. If
you know what libraries you link with, you should know what
exceptions it throws and catch each one. Things may be simplified
if some of these libraries derive their exection classes from
std::exception.

Assuming you use the standard library, you should minimally catch
your local exception, std::exception, and ... . I do this even when
my local exception is derived from std::exception so I can print out
a different message.
 
R

red floyd

Any library you use should specify the exceptions that it throws. If
you know what libraries you link with, you should know what
exceptions it throws and catch each one. Things may be simplified
if some of these libraries derive their exection classes from
std::exception.

Assuming you use the standard library, you should minimally catch
your local exception, std::exception, and ... . I do this even when
my local exception is derived from std::exception so I can print out
a different message.

Sometimes the OS will throw a "..." exception. Win32 comes to mind.
 
A

AnonMail2005

red said:
Sometimes the OS will throw a "..." exception. Win32 comes to mind.
I would hope, then, that the OS will have some way to query it's
state to see if it indeed threw the exception so one could take
approriate action.
 
P

Phlip

I would hope, then, that the OS will have some way to query it's
state to see if it indeed threw the exception so one could take
approriate action.

It's not a ... exception. Research on a Win32 forum how to correctly catch
and process it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,271
Latest member
BuyAtenaLabsCBD

Latest Threads

Top