std::regex_error
From cppreference.com
Defined in header <regex>
|
||
class regex_error : public std::runtime_error {
public: |
(since C++11) | |
Defines the type of object thrown as exceptions to report errors from the regular expressions library.
Contents |
[edit] Member functions
constructs a regex_error object (public member function) |
|
gets the std::regex_constants::error_type for a regex_error (public member function) |
Inherited from std::exception
Member functions
[virtual]
|
destructs the exception object (virtual public member function of std::exception )
|
[virtual]
|
returns an explanatory string (virtual public member function of std::exception )
|
[edit] Example
#include <regex> #include <iostream> int main() { try { std::regex re("[a-b][a"); } catch(const std::regex_error& e) { std::cout << "regex_error caught: " << e.what() << '\n'; if(e.code() == std::regex_constants::error_brack) std::cout << "The code was error_brack\n"; } }
Output:
regex_error caught: The expression contained mismatched [ and ]. The code was error_brack