diff --git a/include/IOException.hpp b/include/IOException.hpp index 1939922..ab3521c 100644 --- a/include/IOException.hpp +++ b/include/IOException.hpp @@ -40,7 +40,7 @@ public: /*! \brief The constructor for an IOException * \param message The error message to throw */ - IOException(const std::string& message) : + inline IOException(const std::string& message) : Exception("IOException: " + message) {} }; diff --git a/include/InvalidDataException.hpp b/include/InvalidDataException.hpp new file mode 100644 index 0000000..b403d5f --- /dev/null +++ b/include/InvalidDataException.hpp @@ -0,0 +1,29 @@ +#ifndef INVALIDDATAEXCEPTION_HPP +#define INVALIDDATAEXCEPTION_HPP + +#include "Exception.hpp" + +namespace zelda +{ +namespace error +{ +/*! \class InvalidDataException + * \brief An exception thrown on Invalid Data calls. + * + * This should only be thrown when the library tries to + * e.g pass a NULL pointer to a function which requires a valid pointer. + *
+ * It is NOT appropriate to use throw new so avoid doing so, + * keeping things on the stack as much as possible is very important for speed. + */ +class InvalidDataException : public Exception +{ +public: + inline InvalidDataException(const std::string& error) + : Exception("InvalidDataException: " + error) + { + } +}; +} +} +#endif // INVALIDDATAEXCEPTION_HPP diff --git a/libzelda.pri b/libzelda.pri index 0e1a87f..7d02833 100644 --- a/libzelda.pri +++ b/libzelda.pri @@ -55,7 +55,8 @@ HEADERS += \ $$PWD/include/SpriteFileReader.hpp \ $$PWD/include/SpriteFileWriter.hpp \ $$PWD/include/SpriteFrame.hpp \ - $$PWD/include/SpritePart.hpp + $$PWD/include/SpritePart.hpp \ + ../libzelda/include/InvalidDataException.hpp SOURCES += \ $$PWD/src/utility.cpp \