Fix a bug not showing the twml_exception dialog.
When called from lua the dialog was no longer show, but only the user part of the message. (Fixes bug #17405.)
This commit is contained in:
parent
96d9e2e129
commit
acba693447
7 changed files with 25 additions and 8 deletions
|
@ -33,6 +33,8 @@ Version 1.9.3+svn:
|
|||
translations.
|
||||
* Add new gui2 drawing widget.
|
||||
* Fix gui2 lines drawing glitch, which happens in some rare cases.
|
||||
* Fixed: Not showing the twml_exception dialog when gui2 was called from
|
||||
lua (bug #17405).
|
||||
* WML engine:
|
||||
* New [harm_unit] tag for damaging, and eventually killing, units.
|
||||
* [allow_recruit], [disallow_recruit] and [set_recruit] now accept a
|
||||
|
|
|
@ -61,7 +61,7 @@ editor_map editor_map::from_string(const config& terrain_cfg, const std::string&
|
|||
} catch (incorrect_map_format_error& e) {
|
||||
throw wrap_exc("format", e.message, "");
|
||||
} catch (twml_exception& e) {
|
||||
throw wrap_exc("wml", e.message, "");
|
||||
throw wrap_exc("wml", e.user_message, "");
|
||||
} catch (config::error& e) {
|
||||
throw wrap_exc("config", e.message, "");
|
||||
}
|
||||
|
|
|
@ -2485,7 +2485,7 @@ int main(int argc, char** argv)
|
|||
std::cerr << "caught end_level_exception (quitting)\n";
|
||||
} catch(twml_exception& e) {
|
||||
std::cerr << "WML exception:\nUser message: "
|
||||
<< e.message << "\nDev message: " << e.dev_message << '\n';
|
||||
<< e.user_message << "\nDev message: " << e.dev_message << '\n';
|
||||
return 1;
|
||||
} catch(game_logic::formula_error& e) {
|
||||
std::cerr << e.what()
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#ifndef lconfig_h
|
||||
#define lconfig_h
|
||||
|
||||
#include "wml_exception.hpp"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
|
||||
|
@ -611,11 +613,15 @@ union luai_Cast { double l_d; long l_l; };
|
|||
** and with longjmp/setjmp otherwise.
|
||||
*/
|
||||
#if defined(__cplusplus)
|
||||
|
||||
|
||||
/* C++ exceptions */
|
||||
#define LUAI_THROW(L,c) throw(c)
|
||||
#define LUAI_TRY(L,c,a) try { \
|
||||
try { a } catch(const std::exception &e) \
|
||||
{ lua_pushstring(L, e.what()); luaG_errormsg(L); throw; } \
|
||||
} catch(twml_exception&) { \
|
||||
throw; \
|
||||
} catch(...) \
|
||||
{ if ((c)->status == 0) (c)->status = -1; }
|
||||
#define luai_jmpbuf int /* dummy variable */
|
||||
|
|
|
@ -223,7 +223,7 @@ BOOST_AUTO_TEST_CASE(test_make_test_fake)
|
|||
gui2::tmessage dlg("title", "message", true);
|
||||
dlg.show(video, 1);
|
||||
} catch(twml_exception& e) {
|
||||
BOOST_CHECK(e.message == _("Failed to show a dialog, "
|
||||
BOOST_CHECK(e.user_message == _("Failed to show a dialog, "
|
||||
"which doesn't fit on the screen."));
|
||||
return;
|
||||
} catch(...) {
|
||||
|
|
|
@ -46,7 +46,7 @@ void twml_exception::show(display &disp)
|
|||
// The extra spaces between the \n are needed, otherwise the dialog doesn't show
|
||||
// an empty line.
|
||||
sstr << _("An error due to possibly invalid WML occurred\nThe error message is :")
|
||||
<< "\n" << message << "\n \n"
|
||||
<< "\n" << user_message << "\n \n"
|
||||
<< _("When reporting the bug please include the following error message :")
|
||||
<< "\n" << dev_message;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef WML_EXCEPTION_HPP_INCLUDED
|
||||
#define WML_EXCEPTION_HPP_INCLUDED
|
||||
|
||||
#include "exceptions.hpp"
|
||||
#include <string>
|
||||
|
||||
class display;
|
||||
|
||||
|
@ -64,13 +64,22 @@ void wml_exception(const char* cond, const char* file,
|
|||
int line, const char *function, const std::string &message);
|
||||
|
||||
/** Helper class, don't construct this directly. */
|
||||
struct twml_exception: game::error
|
||||
struct twml_exception
|
||||
{
|
||||
twml_exception(const std::string &user_msg, const std::string &dev_msg)
|
||||
: game::error(user_msg), dev_message(dev_msg) {}
|
||||
twml_exception(const std::string& user_msg, const std::string& dev_msg)
|
||||
: user_message(user_msg)
|
||||
, dev_message(dev_msg)
|
||||
{
|
||||
}
|
||||
|
||||
~twml_exception() throw() {}
|
||||
|
||||
/**
|
||||
* The message for the user explaining what went wrong. This message can
|
||||
* be translated so the user gets a explanation in his/her native tongue.
|
||||
*/
|
||||
std::string user_message;
|
||||
|
||||
/**
|
||||
* The message for developers telling which problem was triggered, this
|
||||
* shouldn't be translated. It's hard for a dev to parse errors in
|
||||
|
|
Loading…
Add table
Reference in a new issue