When regular expressions are parsed, things can become very complicated. The C++ standard li- brary provides a special exception class to deal with regular-expression exceptions. This class is derived from std::runtime_error (see Section 4.3.1, page 41) and provides an additional mem- ber code() to yield an error code. This might help to find out what’s wrong if an exception is thrown when processing regular expressions.
Unfortunately, the error codes returned by code() are implementation specific, so it doesn’t help to print them directly. Instead, you have to use something like the following header file to deal with regex exceptions in a reasonable way: