-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cpp
60 lines (57 loc) · 1.71 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "MainWindow.h"
#include "Game.h"
#include "ChiliException.h"
int WINAPI wWinMain( HINSTANCE hInst,HINSTANCE,LPWSTR pArgs,INT )
{
try
{
MainWindow wnd( hInst,pArgs );
try
{
Game theGame( wnd );
while( wnd.ProcessMessage() )
{
theGame.Go();
}
}
catch( const ChiliException& e )
{
const std::wstring eMsg = e.GetFullMessage() +
L"\n\nException caught at Windows message loop.";
wnd.ShowMessageBox( e.GetExceptionType(),eMsg );
}
catch( const std::exception& e )
{
// need to convert std::exception what() string from narrow to wide string
const std::string whatStr( e.what() );
const std::wstring eMsg = std::wstring( whatStr.begin(),whatStr.end() ) +
L"\n\nException caught at Windows message loop.";
wnd.ShowMessageBox( L"Unhandled STL Exception",eMsg );
}
catch( ... )
{
wnd.ShowMessageBox( L"Unhandled Non-STL Exception",
L"\n\nException caught at Windows message loop." );
}
}
catch( const ChiliException& e )
{
const std::wstring eMsg = e.GetFullMessage() +
L"\n\nException caught at main window creation.";
MessageBox( nullptr,eMsg.c_str(),e.GetExceptionType().c_str(),MB_OK );
}
catch( const std::exception& e )
{
// need to convert std::exception what() string from narrow to wide string
const std::string whatStr( e.what() );
const std::wstring eMsg = std::wstring( whatStr.begin(),whatStr.end() ) +
L"\n\nException caught at main window creation.";
MessageBox( nullptr,eMsg.c_str(),L"Unhandled STL Exception",MB_OK );
}
catch( ... )
{
MessageBox( nullptr,L"\n\nException caught at main window creation.",
L"Unhandled Non-STL Exception",MB_OK );
}
return 0;
}