Created
August 12, 2016 20:30
-
-
Save russleyshaw/c201248b32b9faa75cd4b586c419d1d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Macro for simple base and inherited exception creation | |
#ifndef _EASY_EXCEPTION_H | |
#define _EASY_EXCEPTION_H | |
#include <exception> | |
#define EASY_EXCEPTION(NAME, WHAT) \ | |
class NAME: public std::exception { \ | |
public: \ | |
virtual const char* what() const noexcept { return WHAT; } \ | |
}; | |
#define EASY_INHERIT_EXCEPTION(NAME, BASE, WHAT) \ | |
class NAME: public BASE { \ | |
public: \ | |
virtual const char* what() const noexcept { return WHAT; } \ | |
}; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example of usage