473,779 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

more information from catch(...)

How can i get more information about the exception when using catch(...)?
Thx in advance
Oct 12 '05 #1
11 1657
Ian
Khuong Dinh Pham wrote:
How can i get more information about the exception when using catch(...)?

You can't.

You have to try a catch specific typed first, like

catch( const std::exception& e )
{
}
catch( ... )
{
}

Ian
Oct 12 '05 #2
Khuong Dinh Pham wrote:
How can i get more information about the exception when using catch(...)?
Thx in advance


No.

--
Stefan Naewe
naewe.s_AT_atla s_DOT_de
Oct 12 '05 #3
* Khuong Dinh Pham:
How can i get more information about the exception when using catch(...)?


You can rethrow the exception (using "throw;") and catch it again with more
specific catch clauses.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Oct 12 '05 #4
On Wed, 12 Oct 2005 08:33:57 +0000, Alf P. Steinbach wrote:
* Khuong Dinh Pham:
How can i get more information about the exception when using catch(...)?


You can rethrow the exception (using "throw;") and catch it again with more
specific catch clauses.


Of course, if you're going to do that you might as well catch the specific
exceptions in the first place... Unless I'm missing something important,
which is entirely possible.

-O

Oct 12 '05 #5
* Owen Jacobson:
On Wed, 12 Oct 2005 08:33:57 +0000, Alf P. Steinbach wrote:
* Khuong Dinh Pham:
How can i get more information about the exception when using catch(...)?


You can rethrow the exception (using "throw;") and catch it again with more
specific catch clauses.


Of course, if you're going to do that you might as well catch the specific
exceptions in the first place... Unless I'm missing something important,
which is entirely possible.


Yes, the possibility of centralizing the exception type determination and
relevant info extraction in a function, thus reducing code redundancy.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Oct 12 '05 #6
Alf P. Steinbach wrote:
* Owen Jacobson:
On Wed, 12 Oct 2005 08:33:57 +0000, Alf P. Steinbach wrote:
* Khuong Dinh Pham: How can i get more information about the exception when using catch(...)?

You can rethrow the exception (using "throw;") and catch it again with more
specific catch clauses.


Of course, if you're going to do that you might as well catch the specific
exceptions in the first place... Unless I'm missing something important,
which is entirely possible.


Yes, the possibility of centralizing the exception type determination and
relevant info extraction in a function, thus reducing code redundancy.


hmm. that sounds like something I want to do. Could you expand on this
a bit?
I'd like to put a bit long list of catches in a function but quite see
how to
do that.
--
Nick Keighley

Oct 12 '05 #7
Alf P. Steinbach wrote:
* Owen Jacobson:
On Wed, 12 Oct 2005 08:33:57 +0000, Alf P. Steinbach wrote:
> * Khuong Dinh Pham:
>> How can i get more information about the exception when using
>> catch(...)?
>
> You can rethrow the exception (using "throw;") and catch it again with
> more specific catch clauses.


Of course, if you're going to do that you might as well catch the
specific
exceptions in the first place... Unless I'm missing something important,
which is entirely possible.


Yes, the possibility of centralizing the exception type determination and
relevant info extraction in a function, thus reducing code redundancy.


Why would I need to catch the exception in the first place if the only thing
to do with it is to throw it again?

Oct 12 '05 #8
* Nick Keighley:
Alf P. Steinbach wrote:
* Owen Jacobson:
On Wed, 12 Oct 2005 08:33:57 +0000, Alf P. Steinbach wrote:
> * Khuong Dinh Pham:> How can i get more information about the exception when using catch(...)?
>
> You can rethrow the exception (using "throw;") and catch it again with more
> specific catch clauses.

Of course, if you're going to do that you might as well catch the specific
exceptions in the first place... Unless I'm missing something important,
which is entirely possible.


Yes, the possibility of centralizing the exception type determination and
relevant info extraction in a function, thus reducing code redundancy.


hmm. that sounds like something I want to do. Could you expand on this
a bit?
I'd like to put a bit long list of catches in a function but quite see
how to
do that.


Trust me, you don't _want_ to do that. But if you're using a bunch of
libraries that can thow various kinds of non-standard exceptions it can be a
more clean approach than the alternatives. It goes like this, off the cuff:

std::string exceptionText()
{
try
{
throw;
}
catch( unsigned x )
{
return "tulso tones exception #" + stringFrom( x );
}
catch( CExpectNot* pOuch )
{
std::string const result =
"Mucho Fishy Casserole exception: " + pOuch->Massage();
pOuch->Destroy();
return result;
}
catch( std::exception const& x )
{
return x.what();
}
catch( ... )
{
return "Unknown exception";
}
}

void foo()
{
try
{
lib1Func(); lib2Func(); lib3Func();
}
catch( ... )
{
throw std::runtime_er ror( exceptionText() );
}
}

and then bar(), similar, and so on.

This technique won't work with version 6.0 and earlier of MSVC, because of a
compiler bug.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Oct 12 '05 #9
* Rolf Magnus:
Alf P. Steinbach wrote:
* Owen Jacobson:
On Wed, 12 Oct 2005 08:33:57 +0000, Alf P. Steinbach wrote:

> * Khuong Dinh Pham:
>> How can i get more information about the exception when using
>> catch(...)?
>
> You can rethrow the exception (using "throw;") and catch it again with
> more specific catch clauses.

Of course, if you're going to do that you might as well catch the
specific
exceptions in the first place... Unless I'm missing something important,
which is entirely possible.


Yes, the possibility of centralizing the exception type determination and
relevant info extraction in a function, thus reducing code redundancy.


Why would I need to catch the exception in the first place if the only thing
to do with it is to throw it again?


See my reply to Nick Keighley.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Oct 12 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

303
17775
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b. Yahoo store was originally written in Lisp. c. Emacs The issues with these will probably come up, so I might as well mention them myself (which will also make this a more balanced
0
1149
by: alanazi | last post by:
hi all, i have a problem here and i hope to have a solution: i am working on an online handwriting recognition project. its idea that a user should have a pen-tablet and write on it his text, my program should recognize what the user writes. the problem that i have is that i don't know how to catch the events of the tablet and how to retreive the information from it.
5
1300
by: | last post by:
Unfortunately I've used exception handling as a debugging tool. Now I want to be smarter about handling errors. Today in the global.asx in the Application_OnError event, I inserted code to email me the Server.GetLastError with some other information. Everythings working fine, but the information about the last error isn't useful. I stilll have to step through the program (VS.NET 2003) to find exactly where the error(s) originate. Tell...
2
2411
by: dan | last post by:
hi ng. i have a asp.net application which is client of an asp.net webservice. now i want to configure a custom error page (in case the sewrvice throws an exception) that provides the soapexception detail property as text. but when defined in web.config, the error page doesn't provide access to the thrown exception anymore. i think that i somehow have to enter the http pipeline to catch the error, read the data and transfer to a error...
2
1119
by: darrel | last post by:
I have a question below about an error I am getting: Exception has been thrown by the target of an invocation. Is there anyway to get asp.net to give me more details than the above? My catch statement is as such: Catch exc As system.Exception div_updateLog.Visible = true lbl_updateLog.text = exc.Message
7
7818
by: Sky | last post by:
I have been looking for a more powerful version of GetType(string) that will find the Type no matter what, and will work even if only supplied "{TypeName}", not the full "{TypeName},{AssemblyName}" As far as I know yet -- hence this question -- there is no 'one solution fits all', but instead there are several parts that have to be put together to check. What I have so far is, and would like as much feedback as possible to ensure I've...
11
7036
by: Don | last post by:
When using Visual Basic .NET with a reference to Interop.Outlook, is there a way to get more detailed information about an error other than Exception.Message or Exception.ToString? For example, Outlook's MailItem.SaveAs method can return an error message of "The operation failed", but I have no idea what that means. As a test, I tried SaveAs using a filename that contained illegal characters and got the error message "Internal Application...
0
4608
by: AxleWacl | last post by:
Hi, The below error is what I am receiving. The code im using is below the error, for the life of me, I can not see where any parameter is missing..... Server Error in '/FleetcubeNews' Application. -------------------------------------------------------------------------------- No value given for one or more required parameters. Description: An unhandled exception occurred during the execution of the current web request. Please...
24
55237
by: =?Utf-8?B?U3dhcHB5?= | last post by:
Can anyone suggest me to pass more parameters other than two parameter for events like the following? Event: Onbutton_click(object sender, EventArgs e)" Event handler: button.Click += new EventHandler(Onbutton_click); I want to pass more information related that event. & want to use that
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10306
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10138
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9930
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.