SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
Exception.hpp
Go to the documentation of this file.
1#ifndef _EXCEPTIONS_H_
2#define _EXCEPTIONS_H_
3
4#include <exception>
5#include <string>
6
7namespace Sleak {
8
9 /// Root of every Sleak-specific exception; carries a plain message string.
10 /// @ingroup utility
11 class SleakException : public std::exception {
12 public:
13 SleakException(const std::string& message) : message_(message) {}
14 virtual const char* what() const noexcept override { return message_.c_str(); }
15
16 protected:
17 std::string message_;
18 };
19
20 /// Thrown when a container index is out of range.
21 /// @ingroup utility
23 public:
24 IndexOutOfBoundsException(const std::string& message = "Index out of bounds")
25 : SleakException(message) {}
26 };
27
28 /// Thrown for invalid iterator use (dereferencing end(), stale iterators, etc.).
29 /// @ingroup utility
31 public:
32 InvalidIteratorException(const std::string& message = "Invalid iterator operation")
33 : SleakException(message) {}
34 };
35
36 /// Thrown when a function receives an argument it can't work with.
37 /// @ingroup utility
39 public:
40 InvalidArgumentException(const std::string& message = "Invalid argument operation")
41 : SleakException(message) {}
42 };
43
44 /// Thrown by operations that require at least one element (e.g. Stack::top on an empty stack).
45 /// @ingroup utility
47 public:
48 EmptyContainerException(const std::string& message = "Container is empty")
49 : SleakException(message) {}
50 };
51
52 /// Thrown when code dereferences or accesses through a null pointer.
53 /// @ingroup utility
55 public:
56 NullPointerException(const std::string& message = "Null pointer access")
57 : SleakException(message) {}
58 };
59
60 /// Thrown when no active camera is registered where one is required.
61 /// @ingroup utility
63 public:
64 CameraNotFound(const std::string& message = "No camera found in static list!")
65 : NullPointerException(message) {}
66 };
67
68 /// Thrown on file read/write failures.
69 /// @ingroup utility
71 public:
72 FileIOException(const std::string& message = "File I/O error")
73 : SleakException(message) {}
74 };
75
76 /// Thrown by stubbed-out code paths that haven't been implemented yet.
77 /// @ingroup utility
79 public:
80 NotImplementedException(const std::string& message = "Not implemented")
81 : SleakException(message) {}
82 };
83}
84
85#endif // _EXCEPTIONS_H_
CameraNotFound(const std::string &message="No camera found in static list!")
Definition Exception.hpp:64
EmptyContainerException(const std::string &message="Container is empty")
Definition Exception.hpp:48
FileIOException(const std::string &message="File I/O error")
Definition Exception.hpp:72
IndexOutOfBoundsException(const std::string &message="Index out of bounds")
Definition Exception.hpp:24
InvalidArgumentException(const std::string &message="Invalid argument operation")
Definition Exception.hpp:40
InvalidIteratorException(const std::string &message="Invalid iterator operation")
Definition Exception.hpp:32
NotImplementedException(const std::string &message="Not implemented")
Definition Exception.hpp:80
NullPointerException(const std::string &message="Null pointer access")
Definition Exception.hpp:56
virtual const char * what() const noexcept override
Definition Exception.hpp:14
SleakException(const std::string &message)
Definition Exception.hpp:13
Root namespace for everything the engine exposes.
Definition Camera.hpp:10