spencercw  committed d0847a8

Display a message box when an error occurs instead of just exiting silently.

  • Participants
  • Parent commits a4ea028
  • Branches default

Comments (0)

Files changed (1)

File gb_emulator_main/main.cpp

     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <>.  */
+#ifdef _WIN32
+// 'argument' : conversion from 'boost::locale::utf::code_point' to 'wchar_t', possible loss of data
+#pragma warning(disable: 4244)
 #include <stdint.h>
 #include <stdlib.h>
 #include <argtable2.h>
 #include <boost/filesystem/operations.hpp>
+#include <boost/locale/encoding_utf.hpp>
 #include <SDL/SDL_main.h>
 #include <gb_emulator/gb.hpp>
 #include <gb_emulator/gb_config.h>
+namespace bl = boost::locale;
 namespace fs = boost::filesystem;
 using std::basic_string;
 using std::clog;
 using std::istringstream;
 using std::streampos;
 using std::string;
+using std::wstring;
 typedef basic_string<uint8_t> ustring;
 	catch (std::exception &e)
 		clog << "An error occurred: " << e.what() << "\n";
+#ifdef _WIN32
+		wstring message = L"An error occurred: " + bl::conv::utf_to_utf<wchar_t>(e.what());
+		MessageBoxW(NULL, message.c_str(), L"Game Boy Emulator", MB_ICONERROR);
 		return EXIT_FAILURE;