|
5 | 5 | #include <memory> |
6 | 6 | #include <stdexcept> |
7 | 7 |
|
| 8 | +#if _WIN32 |
| 9 | +#include <Windows.h> |
| 10 | + |
| 11 | +static void show_error(const char *title, const char *message) |
| 12 | +{ |
| 13 | + fprintf(stderr, "%s: %s\n", title, message); |
| 14 | + MessageBox(NULL, message, title, MB_ICONERROR | MB_OK); |
| 15 | +} |
| 16 | +#else |
| 17 | +#include <SDL2/SDL_messagebox.h> |
| 18 | + |
| 19 | +static void show_error(const char *title, const char *message) |
| 20 | +{ |
| 21 | + fprintf(stderr, "%s: %s\n", title, message); |
| 22 | + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, message, NULL); |
| 23 | +} |
| 24 | +#endif |
| 25 | + |
8 | 26 | int main(int argc, char **argv) |
9 | 27 | { |
10 | 28 | try { |
11 | 29 | std::unique_ptr<aoe::Engine> eng(new aoe::Engine()); |
12 | 30 | return eng->mainloop(); |
13 | | -#if 0 |
| 31 | +#if (defined(_DEBUG) && !_DEBUG) || (defined(NDEBUG) && !NDEBUG) |
14 | 32 | } catch (const std::runtime_error &e) { |
15 | | - fprintf(stderr, "runtime error: %s\n", e.what()); |
| 33 | + show_error("Fatal Runtime Error", e.what()); |
16 | 34 | } catch (const std::exception &e) { |
17 | | - fprintf(stderr, "internal error: %s\n", e.what()); |
| 35 | + show_error("Fatal Internal Error", e.what()); |
18 | 36 | #endif |
19 | 37 | } catch (int v) { |
| 38 | + // a la python: interpret as exit code |
| 39 | + // so we can do something 'clean' like: throw 0; |
20 | 40 | return v; |
21 | 41 | } |
22 | 42 | return 1; |
|
0 commit comments