Main MRPT website > C++ reference for MRPT 1.9.9
error_box.cpp
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+
9  */
10 
11 #include "gui-precomp.h" // Precompiled headers
12 
13 #include <mrpt/gui/error_box.h>
14 #if MRPT_HAS_Qt5
15 #include <QErrorMessage>
16 #include <QString>
17 #else
18 #include <iostream>
19 #endif // MRPT_HAS_Qt5
20 
22  const std::function<void()>& tryPart, const std::string& catchMessage)
23 {
24  try
25  {
26  tryPart();
27  }
28  catch (std::exception& e)
29  {
30  showErrorMessage(catchMessage + e.what());
31  }
32  catch (...)
33  {
34  showErrorMessage("Untyped exception!");
35  }
36 }
37 
39 {
40 #if MRPT_HAS_Qt5
41  QErrorMessage msg;
42  msg.showMessage(QString::fromStdString(str));
43  msg.exec();
44 #elif MRPT_HAS_WXWIDGETS
45  wxMessageBox(_U(str), _("Exception"));
46 #else
47  std::cerr << str << std::endl;
48 #endif // MRPT_HAS_Qt5
49 }
#define _U(x)
Definition: WxSubsystem.h:506
void showErrorMessage(const std::string &str)
Definition: error_box.cpp:38
GLsizei const GLchar ** string
Definition: glext.h:4101
void tryCatch(const std::function< void()> &tryPart, const std::string &catchMessage)
Definition: error_box.cpp:21



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019