forked from SergiusTheBest/exceptxx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cpp
38 lines (33 loc) · 771 Bytes
/
Main.cpp
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
#include <exceptxx/Win32Exception.h>
#include <Windows.h>
#include <iostream>
using namespace std;
int main()
{
try
{
HANDLE h = ::CreateFileW(L"nonexisting", 0, 0, nullptr, OPEN_EXISTING, 0, nullptr);
THROW_LAST_WIN32_IF(INVALID_HANDLE_VALUE == h) << "Ooops, cannot open file 'nonexisting'";
}
catch (const exception& ex)
{
cerr << ex.what() << endl << endl;
}
try
{
THROW_LAST_WIN32_IF(!::ReadFile(nullptr, nullptr, 0, nullptr, nullptr));
}
catch (const exception& ex)
{
cerr << ex.what() << endl << endl;
}
try
{
CHECK_WIN32(ERROR_ACCESS_DENIED);
}
catch (const exception& ex)
{
cerr << ex.what() << endl << endl;
}
return 0;
}