]> jfr.im git - irc/gameservirc.git/blob - gameserv-2.0/libgameservcore/include/GameServ/GameServException.h
Finished some work on FilePlayerDAO
[irc/gameservirc.git] / gameserv-2.0 / libgameservcore / include / GameServ / GameServException.h
1 #ifndef __GS__GAMESERVEXCEPTION_H__
2 #define __GS__GAMESERVEXCEPTION_H__
3
4 #include <string>
5 using std::string;
6
7 namespace GameServ
8 {
9 //! GameServ generic exceptions
10 namespace Exceptions
11 {
12 //! Generic base exception for all GameServ related exceptions that occur
13 /*!
14 These generic exception allows applications and services to catch
15 all exceptions in a generic way, and even pass them off to log files,
16 etc. It's recommended that developers make use of the standard macros
17 __FILE__ and __LINE__. You can compose exception error message strings
18 using boost's format function coupled with boost::str like so:
19 \code
20 // Make a string
21 str(format("Failed to jump rope at time of %1%:%2%") % hour % minute));
22 \endcode
23
24 Developers should use caution when adding exceptions. Exceptions are great
25 for finding errors cross boundries, they shouldn't be used as interrupt handlers
26 or methods to localize handling of error conditions.
27 */
28 class GameServException
29 {
30 public:
31 //! Fully composed exception
32 /*!
33 Recommended construction for a GameServ exception that helps developers and
34 support the most.
35 \param ErrorMsg The custom error message to associated with the
36 exception. Even though this is a reference, it's copied locally to
37 the class.
38 \param Filename The name of the source file, use the standard macro
39 __FILE__
40 \param SourceLine The line number that the error occurred on, use
41 __LINE__
42 */
43 GameServException(const string &ErrorMsg, const char *Filename, int SourceLine);
44
45 //! Partially composed exception
46 /*!
47 Generic message
48 \param ErrorMsg The custom error message to associated with the
49 exception. Even though this is a reference, it's copied locally to
50 the class.
51 */
52 GameServException(const string &ErrorMsg);
53
54 //! Generic exception
55 /*!
56 This is a generic GameServ exception constructor
57 */
58 GameServException(void);
59
60 // Properties /////////////////////////////////////////////////////////////
61
62 //! Property get: Error Message
63 const string ErrorMessage(void) const;
64
65 //! Property get: Source Filename
66 const char *Filename(void) const;
67
68 //! Property get: Source Line Number
69 const int LineNumber(void) const;
70
71 //! Property get: Builds a full error string
72 const string VerboseError(void) const;
73
74 private:
75
76 string mErrorMsg;
77 const char *mpFilename;
78 int mLineNumber;
79
80 };
81 }
82 }
83
84 #endif
85
86
87
88
89
90
91
92