Skip to content

Instantly share code, notes, and snippets.

@todayman
Created March 8, 2013 19:12
Show Gist options
  • Save todayman/5118994 to your computer and use it in GitHub Desktop.
Save todayman/5118994 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <stdexcept>
#include <string>
class CompilerError : public std::runtime_error
{
public:
CompilerError(const std::string& what_arg)
: std::runtime_error(what_arg)
{ }
};
class ScannerError : CompilerError
{
public:
ScannerError(const std::string& msg)
: CompilerError(msg) { }
};
int main()
{
try
{
throw ScannerError("An exception!");
}
catch(CompilerError& e)
{
std::cout << e.what() << '\n';
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment