game_errors.hpp

Go to the documentation of this file.
00001 /* $Id: game_errors.hpp 25276 2008-03-29 11:18:09Z soliton $ */
00002 /*
00003    Copyright (C) 2003 by David White <dave@whitevine.net>
00004    Copyright (C) 2005 - 2008 by Yann Dirson <ydirson@altern.org>
00005    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License version 2
00009    or at your option any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 #ifndef GAME_ERRORS_HPP_INCLUDED
00016 #define GAME_ERRORS_HPP_INCLUDED
00017 
00018 #include <string>
00019 
00020 namespace game {
00021 struct error {
00022     error() : 
00023         message() 
00024         {}
00025     error(const std::string& msg) : message(msg)
00026     {}
00027 
00028     std::string message;
00029 };
00030 
00031 //an exception object used when loading a game fails.
00032 struct load_game_failed : public error {
00033     load_game_failed() {}
00034     load_game_failed(const std::string& msg) : error("load_game_failed: " + msg) {}
00035 };
00036 
00037 //an exception object used when saving a game fails.
00038 struct save_game_failed : public error {
00039     save_game_failed() {}
00040     save_game_failed(const std::string& msg) : error("save_game_failed: " + msg) {}
00041 };
00042 
00043 //an exception object used for any general game error.
00044 //e.g. data files are corrupt.
00045 struct game_error : public error {
00046     game_error(const std::string& msg) : error("game_error: " + msg) {}
00047 };
00048 
00049 //an exception object used to signal that the user has decided to abort
00050 //a game, and load another game instead
00051 struct load_game_exception {
00052     load_game_exception(const std::string& game, bool show_replay, bool cancel_orders) 
00053     : game(game), show_replay(show_replay), cancel_orders(cancel_orders) {}
00054     std::string game;
00055     bool show_replay;
00056     bool cancel_orders;
00057 };
00058 }
00059 
00060 #endif

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs