00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "global.hpp"
00021 #include "wml_exception.hpp"
00022
00023 #include "display.hpp"
00024 #include "gettext.hpp"
00025 #include "show_dialog.hpp"
00026
00027 #include <cassert>
00028 #include <sstream>
00029
00030 void wml_exception(const char* cond, const char* file,
00031 const int line, const char* function, const t_string& message)
00032 {
00033 std::stringstream sstr;
00034 sstr << "Condition '" << cond << "' failed at "
00035 << file << ":" << line << " in function '" << function << "'.";
00036
00037 throw twml_exception(message, sstr.str());
00038 }
00039
00040 twml_exception::twml_exception(const t_string& user_msg, const std::string& dev_msg) :
00041 user_message(user_msg),
00042 dev_message(dev_msg)
00043 {
00044 }
00045
00046 void twml_exception::show(display &disp)
00047 {
00048 std::stringstream sstr;
00049
00050
00051
00052 sstr << _("An error due to possible invalid WML occured\nThe error message is :")
00053 << "\n" << user_message << "\n \n"
00054 << _("When reporting the bug please include the following error message :")
00055 << "\n" << dev_message;
00056
00057 gui::show_error_message(disp, sstr.str());
00058 }
00059
00060 t_string missing_mandatory_wml_key(const std::string& section, const std::string& key,
00061 const std::string& primary_key, const std::string& primary_value)
00062 {
00063 utils::string_map symbols;
00064 symbols["section"] = section;
00065 symbols["key"] = key;
00066 if(!primary_key.empty()) {
00067 assert(!primary_value.empty());
00068
00069 symbols["primary_key"] = primary_key;
00070 symbols["primary_value"] = primary_value;
00071
00072 return t_string(vgettext("In section '[$section|]' where '$primary_key| = "
00073 "$primary_value' the mandatory key '$key|' isn't set.", symbols));
00074 } else {
00075 return t_string(vgettext("In section '[$section|]' the "
00076 "mandatory key '$key|' isn't set.", symbols));
00077 }
00078 }