WORM 0.2
A C++ DAL/ORM code generation framework

src/sql/wsqlerror.h

Go to the documentation of this file.
00001 /*
00002  *    WORM - a DAL/ORM code generation framework
00003  *    Copyright (C) 2011  Erik Winn <erikwinnmail@yahoo.com>
00004  * 
00005  *    This program is free software: you can redistribute it and/or modify
00006  *    it under the terms of the GNU General Public License as published by
00007  *    the Free Software Foundation, either version 3 of the License, or
00008  *    (at your option) any later version.
00009  * 
00010  *    This program is distributed in the hope that it will be useful,
00011  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *    GNU General Public License for more details.
00014  * 
00015  *    You should have received a copy of the GNU General Public License
00016  *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017  */
00018 
00019 #ifndef WSQLERROR_H
00020 #define WSQLERROR_H
00021 
00022 #include <string>
00023 
00024 namespace WSql {
00025 
00026 class  WSqlError
00027 {
00028 public:
00029 
00030     enum ErrorSeverity {
00031         NONE = 0x0,
00032         MESSAGE = 0x01,
00033         WARNING = 0x02,
00034         DANGER = 0x04,
00035         FATAL = 0x08,
00036         ALL = 0xff,
00037     };
00038     enum ErrorType {
00039         UNKNOWN = 0,
00040         DRIVER,
00041         SERVER,
00042         QUERY,
00043         SYSTEM
00044     };
00045 
00046     WSqlError();
00047     WSqlError( const std::string& text, ErrorType type = UNKNOWN);
00048     WSqlError( const std::string& text, 
00049                             int errno = -1,
00050                             ErrorType type = UNKNOWN,
00051                             ErrorSeverity severity = NONE);
00052     
00053     WSqlError(const WSqlError& other);
00054     WSqlError& operator=(const WSqlError& other);
00055     bool operator==(const WSqlError& other)const;
00056     bool operator!=(const WSqlError& other)const{return ! operator==(other);}
00057     ~WSqlError();
00058 
00059     std::string text() const{return _text;}
00060     int errorNumber() const {return _errno;}
00061     ErrorType type() const {return _type;}
00062     ErrorSeverity severity() const {return _severity;}
00063 
00064     void setErrorNumber(int errno){_errno=errno;}
00065     void setText(const std::string& text){_text=text;}
00066     void setType(ErrorType type){_type=type;}
00067     void setSeverity(ErrorSeverity severity){_severity=severity;}
00068 
00069 private:
00070     int _errno;
00071     std::string _text;
00072     ErrorType _type;
00073     ErrorSeverity _severity;
00074 };
00075 
00076 } //namespace WSql
00077 
00078 
00079 #endif // WSQLERROR_H
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Defines