-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNouException.h
More file actions
49 lines (41 loc) · 1.25 KB
/
NouException.h
File metadata and controls
49 lines (41 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#include "NouWin.h"
#include <exception>
#include <string>
class NouException
{
public:
class BaseException : public std::exception
{
public:
BaseException(int line, const char* file) noexcept;
BaseException(int line, const char* file, std::string text) noexcept;
const char* what() const noexcept override;
virtual const char* GetType() const noexcept;
int GetLine() const noexcept;
const std::string& GetFile() const noexcept;
std::string GetOriginString() const noexcept;
private:
int line;
std::string file;
std::string text;
protected:
mutable std::string whatBuffer;
};
class HrException : BaseException
{
public:
HrException(int line, const char* file, HRESULT hr) noexcept;
const char* what() const noexcept override;
virtual const char* GetType() const noexcept;
static std::string TranslateErrorCode(HRESULT hr) noexcept;
HRESULT GetErrorCode() const noexcept;
std::string GetErrorString() const noexcept;
private:
HRESULT hr;
};
};
//MACROS
#define NOU_EXCEPT( hr ) NouException::HrException( __LINE__,__FILE__,hr )
#define NOU_LAST_EXCEPT() NouException::HrException( __LINE__,__FILE__, GetLastError() )
#define CHECK_HR_EXCEPT() if(FAILED(res)) throw NouException::HrException( __LINE__, __FILE__, res);