By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,652 Members | 1,905 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,652 IT Pros & Developers. It's quick & easy.

catch( ... )

P: n/a
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.

Apr 22 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a


Bit byte wrote:
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
}
};

Apr 22 '06 #2

P: n/a
Bit byte wrote:
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?

--
Ian Collins.
Apr 22 '06 #3

P: n/a
Bit byte wrote:
Bit byte wrote:
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
}
};

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.

Apr 23 '06 #4

P: n/a
An**********@gmail.com wrote:
Bit byte wrote:
Bit byte wrote:
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
}
};

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.
Apr 23 '06 #5

P: n/a

red floyd wrote:
An**********@gmail.com wrote:
Bit byte wrote:
Bit byte wrote:

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
}
};

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.

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.

Apr 23 '06 #6

P: n/a
AnonMail2005 wrote:
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.


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

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!
Apr 23 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.