Boost logo

Boost :

From: Hendrik Schober (boost_at_[hidden])
Date: 2002-06-21 06:29:12


"Ted Byers" <r.ted.byers_at_[hidden]> wrote:
> [...]
> However, my base exception also allows for the user (the programmers' using
> code) to set a custom message for each place where an exception can be
> thrown. so you could have something like:
>
> void f(void) {
> ERROR_STACKTRACE_BEGIN
> static std::string msg;
> static const std::string msgA("Here");
> msg = msgA;
> bool rcA = Herefunction();
> ...
> static const std::string msgB("There");
> bool rcB = ThereFunction();
> ...
> ERROR_STACKTRACE_END
> };
>
> This allows a finer granularity in knowing where the exception came from
> without having to give each statement its own try/catch block.

  I don't see the need for this. You can always put
  more of these macros into your code, if you want
  better granularity:

    void f()
    {
      ERROR_STACKTRACE_BEGIN {
        doSomething()
        ERROR_STACKTRACE_BEGIN {
          doMore();
        } ERROR_STACKTRACE_END
        ERROR_STACKTRACE_BEGIN {
          doEvenMore();
        } ERROR_STACKTRACE_END
          doYetMore();
      } ERROR_STACKTRACE_END
    }

  This gets you rid of the string/resource problem.

> [...]
> So then, when the CPU raises a signal that a floating point error has
> occured, we have to wait for the OS (Windows) to convert it into an OS
> exception we can then catch? Or have I misunderstood what is happening when
> an invalid floating point exception is produced by the OS?

  SEHs are a MS thing. The standard way to do this is signals.
  But within a signal handler you can't do much except setting
  an (atomic) flag.
  I don't know much about the details of SEH, but I think these
  exceptions are synchronous. But I really don't knwo that.

> Cheers,
>
> Ted
> [...]

  Schobi


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk