Add exception handling to the demo

This commit is contained in:
Dmitry Marakasov 2013-09-21 04:33:33 +04:00
parent 6e54088c9e
commit 150830b270

View File

@ -19,6 +19,8 @@
3. This notice may not be removed or altered from any source distribution.
*/
#include <iostream>
#include <SDL2/SDL.h>
#include <SDL2pp/SDL2pp.hh>
@ -33,7 +35,7 @@ unsigned char pixels[4 * 4 * 4] = {
RGBA(0x80, 0x00, 0xff, 0xff), RGBA(0x00, 0x00, 0xff, 0xff), RGBA(0x00, 0x80, 0xff, 0xff), RGBA(0x00, 0xff, 0xff, 0xff),
};
int main() {
int Run() {
SDL sdl(SDL_INIT_VIDEO);
Window window("libSDL2pp demo", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_RESIZABLE);
Renderer render(window, -1, SDL_RENDERER_ACCELERATED);
@ -99,3 +101,15 @@ int main() {
return 0;
}
int main() {
try {
return Run();
} catch (Exception& e) {
std::cerr << "Error: " << e.what() << " (" << e.GetSDLError() << ")" << std::endl;
} catch (std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
}
return -1;
}