On Sun, 19 Feb 2012 03:04:35 +0100, Alf P. Steinbach <[email protected]> wrote:

However, C++ exceptions do have many problems, including:

   * Until C++11, no support for propagating exceptions through
     non-exception-aware code (in particular, from C callbacks).

   * No support for wchar_t exception text, i.e. *nix-specific.

   * A nonsensical exception class hierarchy with e.g.
     std::logic_error and std::bad_exception.

   * No differentiation between recoverable (soft, failure) and
     unrecoverable (hard, error) exceptions, although some people have
     argued that in the latter case one is screwed anyway.

   * Involving std::string arguments, so that in low memory
     conditions throwing an exception can itself throw.



Two even worse problems:

a) you see

  foo();

and have no idea whether and what it may throw. No, the documentation is never so detailed and I woudn't trust it anyway.


b) you see

try {
  foo();
} catch (some_exc& e) {
  handle(e);
}

and have no easy way to check whether the 'some_exc' can be really thrown from inside foo(). Maybe not and they forgot to remove the catch.


c) you see

try {
  foo();
} catch (some_exc& e) {
  handle(e);
}

and there's no easy way to spot that the 'some_exc' is already fully handled inside and thus is useless here.



The Java way is overkill but complete ignorance by the compiler isn't good either.

/Pavel

Reply via email to