473,790 Members | 2,629 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
11 1658
On Wed, 12 Oct 2005 10:51:12 GMT, al***@start.no (Alf P. Steinbach)
wrote:
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.


Great idiom. Thank you!

1. You can safely add an exception specification, e.g.
void foo() throw (std::runtime_e rror)

2. A variant of this idiom has recently been posted here:
http://article.gmane.org/gmane.comp....t.devel/132551

Best wishes,
Roland Pibinger
Oct 12 '05 #11
* Roland Pibinger:
2. A variant of this idiom has recently been posted here:
http://article.gmane.org/gmane.comp....t.devel/132551


It's an old idiom. Se my earlier comments regarding MSVC 6.0, and it was old
even then. I first encountered it on this newsgroup, I think that would have
been 1996 or 1997?, but I don't remember who came up with it then, and I don't
know whether that was the first time it was discussed.

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

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

Similar topics

303
17787
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
4610
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
55238
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
9512
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,...
1
10145
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9986
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...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7530
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
5422
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
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4094
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
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.