Boost logo

Boost Users :

From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2007-06-22 13:51:27


Ovanes,

> thanks for the answer. I use VC Express 8.0 with boost 1.34,
> wave comes from the release as well.
> May be the problem is on my side. My main looks like:
>
> int main(int argc, char* argv[])
> {
> try
> {
> cmd_processor cmd(argc, argv);
> cmd.process();
> }

I'ld suggest to add a special catch for the Wave exceptions here:

      catch(boost::wave::cpp_exception const& e)
      {
          // ...
      }

This avoids to use dynamic_cast or other tricks.

> catch(std::exception const& e)
> {
> std::cerr << e.what() << nl << nl;
> return 2;
> }
> catch(...)
> {
> std::cerr << "Unknown exception occured..." <<
> std::endl;
> return 3;
> }
>
> return 0;
> }
>
> After the snippet specified I come into the case with
> std::execption and e.what() returns boost::wave::preprocessor.
>
> Debugging through what()... I came into the class
> preprocess_exception and found additional methods, which give
> me more info. Unfortunately, I rely on the standard
> (std::exception) interface and don't like the idea of writing
> hundres of 'if's or 'else if's or doing many 'dynamic_cast's
> to distinguish exceptions. I believe that every exception
> should give me enough description by calling the what
> function. May be this is stupid... ;)

I hear your point! I tried to look around to get a feeling what other
libraries do and it seems the information returned by Wave's
exception::what() is not the best choice indeed (the standard is very vague
here: essentially it says 'what() should return a implementation defined
null terminated string'). What I'll do for the next verson of Wave (it's too
late for Boost V1.34.1) is to change the exception class to return a string
containing more complete descrption of the error (if you want to do
something on your local copy for now, just change the
preprocess_exception::what() function in cpp_exceptions.hpp to return
description()).

Regards Hartmut


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net