Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct my_exception_type : public logic_error {
- my_exception_type(char const* msg) : logic_error(msg) { }
- };
- try {
- throw my_exception_type("An error occurred");
- } catch (my_exception_type& ex) {
- cerr << ex.what << endl;
- }
- try {
- // …
- }
- catch (...) {
- }
- int foo(int x) try {
- // body of foo
- } catch (...) {
- // be careful what's done here!
- }
- try
- {
- /* code that may throw exceptions */
- }
- catch (Error1 e1)
- {
- /* code if Error1 is thrown */
- }
- catch (Error2 e2)
- {
- /* code if Error2 is thrown */
- }
- catch (...)
- {
- /* any exception that was not expected will be caught here */
- }
Add Comment
Please, Sign In to add comment