Re: Unhandled exception - How to turn off!

Tech-Archive recommends: Fix windows errors by optimizing your registry



bad_cast,
bad_exception,
bad_typeid,
terminate,
type_info,
uncaught_exception,
unexpected

all these functions and classes are deeply language bounded, and reside
in the std namespace.

Yes, in some cases the compiler implicitly calls std library functions,
such as uncaught_exception or unexpected. The compiler has every right to
generate implicit function calls. Those two functions, however, are the
dark side of C++, and the general consensus is that it's better to avoid
them. I wouldn't touch uncaught_exception or exception specifiers with a
10-foot pole:

http://www.gotw.ca/gotw/047.htm
http://www.gotw.ca/gotw/082.htm

A valid use of uncaught_exception function is in the RAII e.g:

class TransactionScope
{
private:
Connection &connection;
public:
TransactionScope(Connection &connection): connection(connection)
{
connection.BeginTransaction();
}
~TransactionScope()
{
if (!std::uncaught_exception())
connection.Commit();
else
connection.Rollback();
}
};

....

Connection &connection = ...

{
TransactionScope transactionScope(connection);

...
}

....
--
Vladimir Nesterovsky


.



Relevant Pages

  • Re: reading a fixed-length message
    ... EOF is generated under all circumstances in a timely fashion? ... disconnect, it doesn't close the connection, it just disappears. ... packed in big-endian order and the above code works purely by chance on ... The compiler only has to compute the expression you've specified, ...
    (comp.unix.programmer)
  • Re: what am I doing wrong ?
    ... close the connection in the finally, because we can't rely on the dispose ... The compiler uses a try..finally block when the using statement is compiled. ... OleDbConnection conn = new OleDbConnection; ... able to handle a particular exception in code, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: I lost the point: purpose of putting objects to null?
    ... compiler would give you a "x may not be initialized" error. ... > What is purpose of putting objects to null: ... > If I make a class, JFrame for example, with button which start connection ... which is class with connection and statement Object. ...
    (comp.lang.java)
  • Re: Scope confusion -- compilation issue -- please help me understand
    ... The problem is that the compiler doesn't know that Environment.Exit never ... So if the constructor for SqlConnection threw an exception (leaving ... connection uninitialised), the compiler would consider the use of connection ...
    (microsoft.public.dotnet.languages.csharp)
  • ATL Compiler Error When Adding Events
    ... I have another problem in that the connection point wizard seems to be using an older version of my type library to generated the connection point. ... ATL Compiler Error When Adding Events ... interfaces and that included entries in the COM MAP for the ...
    (microsoft.public.vc.atl)