MRPT  2.0.4
error_box.cpp
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in https://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 #if MRPT_HAS_WXWIDGETS
21 #include <mrpt/gui/WxUtils.h>
22 #endif
23 
25  const std::function<void()>& tryPart, const std::string& catchMessage)
26 {
27  try
28  {
29  tryPart();
30  }
31  catch (const std::exception& e)
32  {
33  showErrorMessage(catchMessage + e.what());
34  }
35  catch (...)
36  {
37  showErrorMessage("Untyped exception!");
38  }
39 }
40 
41 void mrpt::gui::showErrorMessage(const std::string& str)
42 {
43 #if MRPT_HAS_Qt5
44  QErrorMessage msg;
45  msg.showMessage(QString::fromStdString(str));
46  msg.exec();
47 #elif MRPT_HAS_WXWIDGETS
48  wxMessageBox(str.c_str(), _("Exception"));
49 #else
50  std::cerr << str << std::endl;
51 #endif // MRPT_HAS_Qt5
52 }
void showErrorMessage(const std::string &str)
Definition: error_box.cpp:41
void tryCatch(const std::function< void()> &tryPart, const std::string &catchMessage)
Definition: error_box.cpp:24



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020