Browse Source

Add NullPointerException class

- add NullPointerException class to offer
possibility to throw NullPointerException
Patrick 3 years ago
parent
commit
1c41191fb8
2 changed files with 29 additions and 1 deletions
  1. 2 1
      CMakeLists.txt
  2. 27 0
      source/ls_std/exception/NullPointerException.hpp

+ 2 - 1
CMakeLists.txt

@@ -124,7 +124,8 @@ set(SOURCE_FILES
         ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XMLParseMode.hpp
         ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XMLParseData.hpp
         ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XMLReaderMock.hpp
-        ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XMLReaderMock.cpp)
+        ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XMLReaderMock.cpp
+        ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/exception/NullPointerException.hpp)
 
 set(TEST_FILES
         ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/boxing/IntegerTest.cpp

+ 27 - 0
source/ls_std/exception/NullPointerException.hpp

@@ -0,0 +1,27 @@
+/*
+ * Author:          Patrick-Christopher Mattulat
+ * Company:         Lynar Studios
+ * E-Mail:          webmaster@lynarstudios.com
+ * Created:         2020-11-06
+ * Changed:         2020-11-06
+ *
+ * */
+
+#ifndef LS_STD_NULL_POINTER_EXCEPTION_HPP
+#define LS_STD_NULL_POINTER_EXCEPTION_HPP
+
+#include <exception>
+
+namespace ls_std {
+  class NullPointerException : public std::exception {
+    public:
+
+      explicit NullPointerException() = default;
+
+      const char *what() const noexcept override {
+        return "NullPointerException thrown - reference is null!";
+      }
+  };
+}
+
+#endif