Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

NSError.h

Go to the documentation of this file.
00001 #ifndef _NSError_h_
00002 #define _NSError_h_
00003 
00004 #include <stdlib.h>
00005 #include <errno.h>
00006 
00007 #include <string>
00008 
00009 #include "Debug.h"
00010 #include "Logger.h"
00011 #include "Error.h"
00012 
00013 /*
00014  * 2002-10-17 Herbert Straub: reformatting the print method output (one line)
00015  * 2002-10-22 Herbert Straub: changing NSError::print() to print(), because it
00016  *      produces a wrong Type Information in the logfile.
00017  * 2002-10-29 Herbert Straub: moving VERB in contructor to class Error
00018  */
00019 
00020 /* NSError: ErrorCodes 
00021  */
00022 
00029 class NSError:public Error {
00030       public:
00031         NSError(const char *txt = "unknown"):Error(txt) {
00032         } NSError(const char *txt, const char *file, const char *function,
00033                   int line):Error(txt, file, function, line) {
00034         }
00035         NSError(const string & txt):Error(txt) {
00036         }
00037         NSError(const string & txt, const char *file, const char *function,
00038                 int line):Error(txt, file, function, line) {
00039         }
00040         virtual ~ NSError() {
00041         }
00042 
00043         virtual void print() {
00044                 slog << "Exception! "
00045                     << " Type: NServer"
00046                     << " File: " << _file
00047                     << " Function: " << _function
00048                     << " Line: " << _line << " Desc: " << _errtext << "\n";
00049         }
00050 };
00051 
00058 class NoSuchFieldError:public NSError {
00059       public:
00060         NoSuchFieldError(const char *txt):NSError(txt) {
00061         } NoSuchFieldError(const char *txt, const char *file,
00062                            const char *function, int line):NSError(txt,
00063                                                                    file,
00064                                                                    function,
00065                                                                    line) {
00066         }
00067         NoSuchFieldError(const string & txt):NSError(txt) {
00068         }
00069         NoSuchFieldError(const string & txt, const char *file,
00070                          const char *function, int line):NSError(txt, file,
00071                                                                  function,
00072                                                                  line) {
00073         }
00074 
00075         virtual void print() {
00076                 slog << "Exception!"
00077                     << " Type: NotFound"
00078                     << " File: " << _file
00079                     << " Function: " << _function
00080                     << " Line: " << _line << " Desc: " << _errtext << "\n";
00081         }
00082 };
00083 
00090 class NoNewsServerError:public NSError {
00091       public:
00092         NoNewsServerError(const char *txt = "unknown"):NSError(txt) {
00093         } NoNewsServerError(const char *txt, const char *file,
00094                             const char *function, int line):NSError(txt,
00095                                                                     file,
00096                                                                     function,
00097                                                                     line) {
00098         }
00099         NoNewsServerError(const string & txt):NSError(txt) {
00100         }
00101         NoNewsServerError(const string & txt, const char *file,
00102                           const char *function, int line):NSError(txt,
00103                                                                   file,
00104                                                                   function,
00105                                                                   line) {
00106         }
00107 
00108         virtual void print() {
00109                 slog << "Exception!"
00110                     << " Type: NoNewsServer"
00111                     << " File: " << _file
00112                     << " Function: " << _function
00113                     << " Line: " << _line << " Desc: " << _errtext << "\n";
00114         }
00115 };
00116 
00123 class NoSuchGroupError:public NSError {
00124       public:
00125         NoSuchGroupError(const char *txt = "unknown"):NSError(txt) {
00126         } NoSuchGroupError(const char *txt, const char *file,
00127                            const char *function, int line):NSError(txt,
00128                                                                    file,
00129                                                                    function,
00130                                                                    line) {
00131         }
00132         NoSuchGroupError(const string & txt):NSError(txt) {
00133         }
00134         NoSuchGroupError(const string & txt, const char *file,
00135                          const char *function, int line):NSError(txt, file,
00136                                                                  function,
00137                                                                  line) {
00138         }
00139 
00140         virtual void print() {
00141                 slog << "Exception!"
00142                     << " Type: NoSuchGroup"
00143                     << " File: " << _file
00144                     << " Function: " << _function
00145                     << " Line: " << _line << " Desc: " << _errtext << "\n";
00146         }
00147 };
00148 
00155 class DuplicateArticleError:public NSError {
00156       public:
00157         DuplicateArticleError(const char *txt = "unknown"):NSError(txt) {
00158         } DuplicateArticleError(const char *txt, const char *file,
00159                                 const char *function,
00160                                 int line):NSError(txt, file, function,
00161                                                   line) {
00162         }
00163         DuplicateArticleError(const string & txt):NSError(txt) {
00164         }
00165         DuplicateArticleError(const string & txt, const char *file,
00166                               const char *function, int line):NSError(txt,
00167                                                                       file,
00168                                                                       function,
00169                                                                       line)
00170         {
00171         }
00172 
00173         virtual void print() {
00174                 slog << "Exception!"
00175                     << " Type: DuplicateArticle"
00176                     << " File: " << _file
00177                     << " Function: " << _function
00178                     << " Line: " << _line << " Desc: " << _errtext << "\n";
00179         }
00180 };
00181 
00188 class NoSuchArticleError:public NSError {
00189       public:
00190         NoSuchArticleError(const char *txt = "unknown"):NSError(txt) {
00191         } NoSuchArticleError(const char *txt, const char *file,
00192                              const char *function, int line):NSError(txt,
00193                                                                      file,
00194                                                                      function,
00195                                                                      line)
00196         {
00197         }
00198         NoSuchArticleError(const string & txt):NSError(txt) {
00199         }
00200         NoSuchArticleError(const string & txt, const char *file,
00201                            const char *function, int line):NSError(txt,
00202                                                                    file,
00203                                                                    function,
00204                                                                    line) {
00205         }
00206 
00207         virtual void print() {
00208                 slog << "Exception!"
00209                     << " Type: NoSuchArticle"
00210                     << " File: " << _file
00211                     << " Function: " << _function
00212                     << " Line: " << _line << " Desc: " << _errtext << "\n";
00213         }
00214 };
00215 
00222 class PostingFailedError:public NSError {
00223       public:
00224         PostingFailedError(const char *txt = "unknown"):NSError(txt) {
00225         } PostingFailedError(const char *txt, const char *file,
00226                              const char *function, int line):NSError(txt,
00227                                                                      file,
00228                                                                      function,
00229                                                                      line)
00230         {
00231         }
00232         PostingFailedError(const string & txt):NSError(txt) {
00233         }
00234         PostingFailedError(const string & txt, const char *file,
00235                            const char *function, int line):NSError(txt,
00236                                                                    file,
00237                                                                    function,
00238                                                                    line) {
00239         }
00240 
00241         virtual void print() {
00242                 slog << "Exception!"
00243                     << " Type: PostingFailedError"
00244                     << " File: " << _file
00245                     << " Function: " << _function
00246                     << " Line: " << _line << " Desc: " << _errtext << "\n";
00247         }
00248 };
00249 
00250 class NotAllowedError:public NSError {
00251       public:
00252         NotAllowedError(const char *txt = "unknown"):NSError(txt) {
00253         } NotAllowedError(const char *txt, const char *file,
00254                           const char *function, int line):NSError(txt,
00255                                                                   file,
00256                                                                   function,
00257                                                                   line) {
00258         }
00259         NotAllowedError(const string & txt):NSError(txt) {
00260         }
00261         NotAllowedError(const string & txt, const char *file,
00262                         const char *function, int line):NSError(txt, file,
00263                                                                 function,
00264                                                                 line) {
00265         }
00266 
00267         virtual void print() {
00268                 slog << "Exception!"
00269                     << " Type: NoSuchArticle"
00270                     << " File: " << _file
00271                     << " Function: " << _function
00272                     << " Line: " << _line << " Desc: " << _errtext << "\n";
00273         }
00274 };
00275 
00282 class UsageError:public NSError {
00283       public:
00284         UsageError(const char *txt = "unknown"):NSError(txt) {
00285         } UsageError(const char *txt, const char *file,
00286                      const char *function, int line):NSError(txt, file,
00287                                                              function,
00288                                                              line) {
00289         }
00290         UsageError(const string & txt):NSError(txt) {
00291         }
00292         UsageError(const string & txt, const char *file,
00293                    const char *function, int line):NSError(txt, file,
00294                                                            function,
00295                                                            line) {
00296         }
00297 
00298         virtual void print() {
00299                 slog << "Exception!"
00300                     << " Type: Usage"
00301                     << " File: " << _file
00302                     << " Function: " << _function
00303                     << " Line: " << _line << " Desc: " << _errtext << "\n";
00304         }
00305 };
00306 typedef UsageError UsageErr;
00307 
00314 class ResponseError:public NSError {
00315       public:
00316         string _command;
00317         string _expected;
00318         string _got;
00319 
00320          ResponseError() {
00321         } ResponseError(const char *command, const char *exp,
00322                         const char *got)
00323         :_command(command), _expected(exp), _got(got) {
00324                 slog.p(Logger::Error);
00325                 ResponseError::print();
00326         }
00327         ResponseError(const char *command, const char *exp,
00328                       const string & got)
00329         :_command(command), _expected(exp), _got(got) {
00330                 slog.p(Logger::Error);
00331                 ResponseError::print();
00332         }
00333         ResponseError(const string & command, const string & exp,
00334                       const string & got)
00335         :_command(command), _expected(exp), _got(got) {
00336                 slog.p(Logger::Error);
00337                 ResponseError::print();
00338         }
00339 
00340         virtual void print() {
00341                 slog << "Exception!"
00342                     << " Type: Response"
00343                     << " File: " << _file
00344                     << " Function: " << _function
00345                     << " Line: " << _line
00346                     << " Cmd : " << _command
00347                     << " Exp : " << _expected << " Got : " << _got << "\n";
00348         }
00349 };
00350 typedef ResponseError ResponseErr;
00351 
00352 #endif

Generated on Sun Oct 24 21:08:18 2004 for NewsCache by doxygen 1.3.6-20040222