Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Error.hpp
1 // Copyright (C) 2017 Jérôme Leclercq
2 // This file is part of the "Nazara Engine - Core module"
3 // For conditions of distribution and use, see copyright notice in Config.hpp
4 
5 #pragma once
6 
7 #ifndef NAZARA_ERROR_HPP
8 #define NAZARA_ERROR_HPP
9 
10 #include <Nazara/Prerequesites.hpp>
11 #include <Nazara/Core/Config.hpp>
12 #include <Nazara/Core/Enums.hpp>
13 #include <Nazara/Core/String.hpp>
14 
15 #if NAZARA_CORE_ENABLE_ASSERTS || defined(NAZARA_DEBUG)
16  #define NazaraAssert(a, err) if (!(a)) Nz::Error::Trigger(Nz::ErrorType_AssertFailed, err, __LINE__, __FILE__, NAZARA_FUNCTION)
17 #else
18  #define NazaraAssert(a, err) for (;;) break
19 #endif
20 
21 #define NazaraError(err) Nz::Error::Trigger(Nz::ErrorType_Normal, err, __LINE__, __FILE__, NAZARA_FUNCTION)
22 #define NazaraInternalError(err) Nz::Error::Trigger(Nz::ErrorType_Internal, err, __LINE__, __FILE__, NAZARA_FUNCTION)
23 #define NazaraWarning(err) Nz::Error::Trigger(Nz::ErrorType_Warning, err, __LINE__, __FILE__, NAZARA_FUNCTION)
24 
25 namespace Nz
26 {
27  class NAZARA_CORE_API Error
28  {
29  public:
30  Error() = delete;
31  ~Error() = delete;
32 
33  static UInt32 GetFlags();
34  static String GetLastError(const char** file = nullptr, unsigned int* line = nullptr, const char** function = nullptr);
35  static unsigned int GetLastSystemErrorCode();
36  static String GetLastSystemError(unsigned int code = GetLastSystemErrorCode());
37 
38  static void SetFlags(UInt32 flags);
39 
40  static void Trigger(ErrorType type, const String& error);
41  static void Trigger(ErrorType type, const String& error, unsigned int line, const char* file, const char* function);
42 
43  private:
44  static UInt32 s_flags;
45  static String s_lastError;
46  static const char* s_lastErrorFunction;
47  static const char* s_lastErrorFile;
48  static unsigned int s_lastErrorLine;
49  };
50 }
51 
52 #endif // NAZARA_ERROR_HPP
TODO: Inherit SoundEmitter from Node.
Definition: Algorithm.hpp:12
Core class that represents a string.
Definition: String.hpp:22
Core class that represents an error.
Definition: Error.hpp:27