From 0531bf802017b7792b90270b6346b3c88ffcea70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Mon, 18 Jul 2022 02:46:00 +0200 Subject: Improve exception message. --- c/main.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'c') diff --git a/c/main.cpp b/c/main.cpp index 24fc19f..951770a 100644 --- a/c/main.cpp +++ b/c/main.cpp @@ -51,14 +51,18 @@ void OnTerminate() try { std::rethrow_exception(std::current_exception()); } catch (const term_t& t) { + std::basic_string tstr = TEXT("The program was terminated due to a Prolog exception: "); TCHAR* tsz; if (PL_get_tchars(t, &tsz, CVT_WRITE)) { - MessageBox(NULL, tsz, TEXT("Fatal Error"), MB_ICONERROR); + tstr += tsz; + MessageBox(NULL, tstr.c_str(), TEXT("Fatal Error"), MB_ICONERROR); } else MessageBoxA(NULL, "The program was terminated due to a Prolog exception.", "Fatal Error", MB_ICONERROR); } catch (std::exception& e) { - MessageBoxA(NULL, e.what(), "Fatal Error", MB_ICONERROR); + std::string str = "The program was terminated due to an exception: "; + str += e.what(); + MessageBoxA(NULL, str.c_str(), "Fatal Error", MB_ICONERROR); } catch (...) { MessageBoxA(NULL, "The program was terminated due to an exception.", "Fatal Error", MB_ICONERROR); -- cgit v1.2.3