Skip to content

Instantly share code, notes, and snippets.

@arg0
Created September 8, 2016 10:10
Show Gist options
  • Save arg0/fd050bc041ae1f33a0579d4fbbf36a89 to your computer and use it in GitHub Desktop.
Save arg0/fd050bc041ae1f33a0579d4fbbf36a89 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <exception>
using namespace std;
struct MyException : public exception
{
const char * what () const throw ()
{
return "C++ Exception";
}
};
int main()
{
try
{
throw MyException();
}
catch(MyException& e)
{
std::cout << "MyException caught" << std::endl;
std::cout << e.what() << std::endl;
}
catch(std::exception& e)
{
//Other errors
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment