Advertisement
shadowm

Untitled

May 4th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1.     } catch(wesnothd_error& e) {
  2.         if(!e.message.empty()) {
  3.             ERR_NET << "caught network error: " << e.message << std::endl;
  4.  
  5.             std::string user_msg;
  6.  
  7.             if(dynamic_cast<wesnothd_connection_error*>(&e)) {
  8.                 // The wesnothd_connection_error subclass is only thrown with messages
  9.                 // from boost::system::error_code which we can't translate ourselves.
  10.                 // It's also the originator of the infamous EOF error that happens when
  11.                 // the server dies. <https://github.com/wesnoth/wesnoth/issues/3005>
  12.                 if(e.message == "End of file") {
  13.                     user_msg = _("Disconnected from server.");
  14.                 } else if(e.message == "Connection refused") {
  15.                     user_msg = _("Server is offline.");
  16.                 } else {
  17.                     user_msg = _("Connection error: ") + translation::gettext(e.message.c_str());
  18.                 }
  19.             } else {
  20.                 // This will be a message from the server itself, which we can
  21.                 // probably translate.
  22.                 user_msg = translation::gettext(e.message.c_str());
  23.             }
  24.  
  25.             gui2::show_transient_error_message(user_msg);
  26.         } else {
  27.             ERR_NET << "caught network error" << std::endl;
  28.         }
  29.     } catch(config::error& e) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement