diff -r 911927edbdde -r 50308ed5e4f9 sdlterm/src/sdlterm.cc --- a/sdlterm/src/sdlterm.cc Tue Jan 08 01:12:07 2013 +0100 +++ b/sdlterm/src/sdlterm.cc Tue Jan 08 23:36:01 2013 +0100 @@ -1,6 +1,5 @@ #include "sdlterm.h" -#include #include @@ -44,8 +43,7 @@ { if (TTF_Init() == -1) { - printf("TTF_Init: %s\n", TTF_GetError()); - throw std::exception(); + throw SDLTermError(std::string("TTF_Init: ") + TTF_GetError()); } } @@ -66,23 +64,21 @@ _font_regular = TTF_OpenFont(fname_regular, ptsize); if (!_font_regular) { - printf("TTF_OpenFont: %s\n", TTF_GetError()); - throw std::exception(); + throw SDLTermError(std::string("TTF_OpenFont: ") + TTF_GetError()); } // open bold font _font_bold = TTF_OpenFont(fname_bold, ptsize); if (!_font_bold) { - printf("TTF_OpenFont: %s\n", TTF_GetError()); - throw std::exception(); + throw SDLTermError(std::string("TTF_OpenFont: ") + TTF_GetError()); } // update metrics for regular font int advance; if (TTF_GlyphMetrics(_font_regular, 'M', NULL, NULL, NULL, NULL, &advance) == -1) { - printf("TTF_GlyphMetrics: %s\n", TTF_GetError()); + throw SDLTermError(std::string("TTF_GlyphMetrics: ") + TTF_GetError()); } _cell_width = advance; _cell_height = TTF_FontHeight(_font_regular); @@ -90,7 +86,7 @@ // read metrics for bold font if (TTF_GlyphMetrics(_font_bold, 'M', NULL, NULL, NULL, NULL, &advance) == -1) { - printf("TTF_GlyphMetrics: %s\n", TTF_GetError()); + throw SDLTermError(std::string("TTF_GlyphMetrics: ") + TTF_GetError()); } if (advance > _cell_width) { @@ -221,8 +217,7 @@ if (_screen_surface == NULL) { - fprintf(stderr, "Unable to set video: %s\n", SDL_GetError()); - throw std::exception(); + throw SDLTermError(std::string("SDL_SetVideoMode: ") + SDL_GetError()); } _pixel_width = pxwidth; @@ -312,8 +307,7 @@ { if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) == -1) { - fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError()); - throw std::exception(); + throw SDLTermError(std::string("SDL_Init: ") + SDL_GetError()); } SDL_EnableUNICODE(1); SDL_EnableKeyRepeat(250, SDL_DEFAULT_REPEAT_INTERVAL); @@ -436,8 +430,7 @@ break; // continue loop } } - fprintf(stderr, "SDL_WaitEvent error: %s\n", SDL_GetError()); - throw std::exception(); + throw SDLTermError(std::string("SDL_WaitEvent: ") + SDL_GetError()); }