473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

catch( ... )

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
6 1646


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

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Gary.Hu | last post by:
I was trying to catch the Arithmetic exception, unsuccessfully. try{ int a = 0, b = 9; b = b / a; }catch(...){ cout << "arithmetic exception was catched!" << endl; } After ran the program,...
11
by: kaeli | last post by:
Hey all, I'd like to start using the try/catch construct in some scripts. Older browsers don't support this. What's the best way to test for support for this construct so it doesn't kill...
4
by: Abhishek Srivastava | last post by:
Hello All, I have seen code snippets like try { ..... } catch {
11
by: Pohihihi | last post by:
I was wondering what is the ill effect of using try catch in the code, both nested and simple big one. e.g. try { \\ whole app code goes here } catch (Exception ee) {}
13
by: Benny | last post by:
Hi, I have something like this: try { // some code } catch // note - i am catching everything now {
23
by: VB Programmer | last post by:
Variable scope doesn't make sense to me when it comes to Try Catch Finally. Example: In order to close/dispose a db connection you have to dim the connection outside of the Try Catch Finally...
32
by: cj | last post by:
Another wish of mine. I wish there was a way in the Try Catch structure to say if there wasn't an error to do something. Like an else statement. Try Catch Else Finally. Also because I...
23
by: pigeonrandle | last post by:
Hi, Does this bit of code represent complete overkill?! try { //create a treenode TreeNode tn = new TreeNode(); //add it to a treeview tv.Nodes.Add(tn);
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.