Guest User

Untitled

a guest
Nov 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include "error_handler.hpp"
  2.  
  3. #ifndef ERROR_HANDLER
  4. #define ERROR_HANDLER PRINT_AND_GRILL
  5. #endif
  6.  
  7. using namespace std;
  8.  
  9. #if ERROR_HANDLER == PRINT_AND_GRILL
  10. #include <cstdlib>
  11. #include <iostream>
  12.  
  13. #ifdef __WIN32__
  14. #include <windows.h>
  15. #endif
  16.  
  17. #ifdef __OBJC__
  18. #import <Cocoa/Cocoa.h>
  19. #endif
  20.  
  21. void handle_error(error_type type, string const& msg) {
  22. #ifdef __WIN32__
  23.     MessageBox(NULL, msg.c_str(), "Lua Error", MB_ICONERROR | MB_OK | MB_TASKMODAL);
  24. #elif __OBJC__
  25.     NSAlert *alert = [[NSAlert alloc] init];
  26.         [alert setMessage:@"LUA Error"];
  27.         [alert setInformativeText:[NSString stringWithUTF8String:msg.c_str()]];
  28.         [alert runModal];
  29.     [alert autorelease];
  30. #else
  31.     cout << "lua error: " << msg << endl;
  32. #endif
  33.     exit(EXIT_SUCCESS);
  34. }
  35.  
  36. #endif
Add Comment
Please, Sign In to add comment