473,804 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

throw exception();

Josuttis states that I may not throw an exception of type exception or of
one of the standard exception types used for language support. Where in the
Standard am I forbidden from "throw exception();"?

Thanks,
Dave
Jul 22 '05 #1
2 1578
Dave wrote:
Josuttis states that I may not throw an exception of type exception or of
one of the standard exception types used for language support. Where in
the Standard am I forbidden from "throw exception();"?


I think the following will explain to you about all the exception types.

http://www.cplusplus.com/doc/tutorial/tut5-3.html

--
Roy Schestowitz
http://schestowitz.com
Jul 22 '05 #2
Roy Schestowitz wrote:
Dave wrote:

I think the following will explain to you about all the exception types.

http://www.cplusplus.com/doc/tutorial/tut5-3.html


There are some things in this document I'd like to point out.
First, not really relevant to the topic at hand, that it uses <iostream.h>,
when it really should use <iostream>.

Second, and more importantly, it's got the wrong reason listed for when a
bad_exception is thrown. The document claims it's when "an exception
doesn't match any catch". This is wrong. The exception is thrown when an
exception doesn't match an explicit throws clause:
void foo() throws (std::runtime_e rror)
{
throw std::length_err or();
}

I'm not sure why Josuttis would state that you MAY NOT throw a plain
std::exception - as far as I'm aware, nothing in the standard says so. But
you SHOULD NOT throw a plain std::exception, simply because it holds no
further information to the cause of the error. Always be as specific as is
reasonable.

--
Sebastian Redl
Jul 22 '05 #3

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

Similar topics

3
458
by: Kerri | last post by:
Hi, I am new to .NET In my Error Logic on my Aspx pages when an error happens it hits my catch statement where I throw an Exception. My question is : what is the difference between Thwo Exception and Throw
4
1986
by: Eric Lilja | last post by:
Hello, in my program I have a function (pseudo code): void start_mysql_service() { obtain handle start mysql service using handle if start fails close handle and throw an exception containing error description
3
3506
by: Pierre Rouleau | last post by:
The std::exception class defined in the Standard C++ <exception> header specifies that the constructors could throw any exception becuase they do not have a throw() specification. Why is that? Is this because there could be an exception thrown when the code creates a std::exception? I would assume that is not the case. However, if I want to create a new exception class, derived from std::exception (say MyException) then how can I...
0
1152
by: Lasse Vågsæther Karlsen | last post by:
From the book by Jeffrey Richter: throw; will not change the origin of the exception, whereas throw ex; will change the origin of the exception to this statement. When I try the following program, I get this result: 3: at ... in c:\dev\vs.net\exceptiontest3\form1.cs:line 91 2: at ... in c:\dev\vs.net\exceptiontest3\form1.cs:line 101 1: at ... in c:\dev\vs.net\exceptiontest3\form1.cs:line 101
17
1961
by: hplloyd | last post by:
Hi, I have a function that adds data to a database and I want to return true if the database was updated and false if there was a problem, so I am using a try... catch block... My problem is that I can return true ok is the routine succeeds but where do I put the return false; statement id the process fails - I get a compile error say unreachable code with whatever i try...
6
5722
by: Arjen | last post by:
Hi, I'm reading the enterprise library documentation and there I see the throw statement. try { // run code } catch(Exception ex) {
6
11643
by: Henryk | last post by:
I did a lot of delphi GUI programming recently. In my experience most of the time you just want to throw a standard exception with a descriptive message. Then all calling functions can handle this exception as they like and finally show a message to the user or not. Only in a few occasions I need some special exception types to behave differently depending on the error. So what you basically do is
6
2052
by: Fir5tSight | last post by:
Hi, What does "throw" do? I understand that it throws an error when certain exceptional situation happens. My guess is that this *ignores* the error and *continues* so that it prevents the program from crashing. I just don't know where it throws the error to? It makes sense if it outputs the error into a log file. Please let me know if my thoughts are correct.
28
2861
by: Jess | last post by:
Hello, It is said that if I implement a "swap" member function, then it should never throw any exception. However, if I implement "swap" non- member function, then the restriction doesn't apply. Can somebody tell me why? Thanks, Jess
6
1965
by: jason.cipriani | last post by:
Consider this program, which defines a template class who's template parameter is the type of an exception that can be thrown by members of the class: === BEGIN EXAMPLE === #include <iostream> #include <string> using namespace std;
0
9711
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10595
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
10343
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...
1
10335
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
9169
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
7633
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
6862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5668
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3001
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.