Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Amend request (throwing error)

90 views
Skip to first unread message

WIJ

unread,
Mar 18, 2016, 2:20:08 PM3/18/16
to

The concept and usage of error handling mechanism(throw,catch) should
have now been more widely understood through painful experiences that
it isn't suitable at all for the general programming idea of
'error handling'. For instance:

void f(int v)
{
if(v<5) throw std::invalid_argument("v<5");
...
};

void g() try {
f(2);
}
catch(std::invalid_argument& e) {
// 1. The captured e is sensitive to the context, e.g. any functions
// used particularly implicit ones, and library linked.
// 2. No guarantee e is what the programmer expected!
};

The impact is deep in any C++ components using ctor,dtor or operator=,
..,etc, involving implicit conversions. Since the globally practical
function of the standard is educational. Text books and derivatives
have to be written on documents published by the standard committee or
C++ authorities. People writting documents feels difficult addressing
it differently. Please consider removing such 'error handling' suggest
and add some warning addressing or amend this issue.



--
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp...@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]

0 new messages