Discussion Locked

Handle errors in C++

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Do you find exception errors easier to deal with in Java than in C++? How do you handle exception errors in C++?

5 replies

by dfumagalli

I am a very satisfied Borland C++ Builder 6 user and I make heavy use of its VCL library built in exception classes.
New exceptions are as easy as deriving a descendant of one of the available classes, which already cover the most common situations.

For the best enterprise end user ease of reporting of errors, I often derive very useful exception handlers (aided by macros) that show onscreen the exact application, module file, line and error message where the exception occurred. At the sametime they (optionally) log the same error messages to a file.

Best regards,
Dario Fumagalli

by mike owens

I make heavy use of BCB 5 and the VCL happens to be the exception. The reason it is the exception, is that the VCL is written in Object Pascal instead of C++. So you can't technically hold it up as a C++ library that uses exceptions. The only reasonthat this would matter is for C++ purists because using the VCL means that you have to give up some minor C++ functionality. I definately like BCB though and I have never missed multiple inheritance while using the VCL.

by Mark W. Kaelin

This is the text of an e-mail received concerning this article. The reader has some interesting comments:

"Unfortunately the article recommends as positive something that is
actually considered to have emerged as a poor practice in the C++
community, and therefore that should avoided not encouraged.

The C++ committee is generally of the opinion that throw specs were an
experiment that failed, although the design of throw specs was clearly
filled with good intentions. Many coding guidelines (see
http://boost.org) now ban throw specs, with the occasional admission of
empty throw specs.

The article starts off praising Java's model of checked exceptions.
However, those too are considered by some to be an experiment that
failed, albeit for slightly different reasons: http://www.mindview.net/E
tc/Discussions/CheckedExceptions."

by mike owens

I agree that throw specs we're poorly implemented or probably a better explanation would be they were only partially implemented. The idea behind bringing throw specs up in the article was how to implement an exception architecture similar to Java's.

I happen to not agree with you on your opinion of Java's exception architecture. I think it is one of the best features in Java and is very thorough and well thought out.

by jdieter2

C++ makes binaries. Java interprets scripts. My God, how can any sane computer professional compare the two? On the one hand, your program is compiled into a binary, ready for the OS loader. On the other, you use some secret program written by someone else to "interpret" your script. I can compile my C++ compiler. I have every bit (pun intended) of code that makes my program into machine language. My program is secure, java and .net are not. Even for web sites, at least I have the code to PHP. Granted it's a script, but I still have the code. You don't have the source code? You can't compile your compiler? You are not a programmer. You are a user. Luser Luser!

This discussion is closed to new replies.