00001 /* 00002 * 00003 * Copyright Jonathan Schaeffer 2010, CC-IN2P3, CNRS <jonathan.schaeffer@cc.in2p3.fr> 00004 * Contributors : Andres Gomez, CC-IN2P3, CNRS <andres.gomez@cc.in2p3.fr> 00005 * 00006 * This software is a computer program whose purpose is to schedule, sort 00007 * and submit file requests to the hierarchical storage system HPSS. 00008 * 00009 * This software is governed by the CeCILL license under French law and 00010 * abiding by the rules of distribution of free software. You can use, 00011 * modify and/or redistribute the software under the terms of the CeCILL 00012 * license as circulated by CEA, CNRS and INRIA at the following URL 00013 * "http://www.cecill.info". 00014 * 00015 * As a counterpart to the access to the source code and rights to copy, 00016 * modify and redistribute granted by the license, users are provided only 00017 * with a limited warranty and the software's author, the holder of the 00018 * economic rights, and the successive licensors have only limited 00019 * liability. 00020 * 00021 * In this respect, the user's attention is drawn to the risks associated 00022 * with loading, using, modifying and/or developing or reproducing the 00023 * software by the user in light of its specific status of free software, 00024 * that may mean that it is complicated to manipulate, and that also 00025 * therefore means that it is reserved for developers and experienced 00026 * professionals having in-depth computer knowledge. Users are therefore 00027 * encouraged to load and test the software's suitability as regards their 00028 * requirements in conditions enabling the security of their systems and/or 00029 * data to be ensured and, more generally, to use and operate it in the 00030 * same conditions as regards security. 00031 * 00032 * The fact that you are presently reading this means that you have had 00033 * knowledge of the CeCILL license and that you accept its terms. 00034 * 00035 */ 00036 /* 00037 * ============================================================================= 00038 * 00039 * Filename: Exceptions.h 00040 * 00041 * Description: Exceptions used by the program 00042 * 00043 * Version: 1.0 00044 * Created: 20/05/2009 10:57:26 00045 * Revision: none 00046 * Compiler: gcc 00047 * 00048 * Copyright Jonathan Schaeffer 2009-2010, 00049 * CC-IN2P3, CNRS <jonathan.schaeffer@cc.in2p3.fr> 00050 * Contributors : Andres Gomez, 00051 * CC-IN2P3, CNRS <andres.gomez@cc.in2p3.fr> 00052 * 00053 * This software is a computer program whose purpose is to schedule, sort 00054 * and submit file requests to the hierarchical storage system HPSS. 00055 * 00056 * This software is governed by the CeCILL license under French law and 00057 * abiding by the rules of distribution of free software. You can use, 00058 * modify and/or redistribute the software under the terms of the CeCILL 00059 * license as circulated by CEA, CNRS and INRIA at the following URL 00060 * "http://www.cecill.info". 00061 * 00062 * As a counterpart to the access to the source code and rights to copy, 00063 * modify and redistribute granted by the license, users are provided only 00064 * with a limited warranty and the software's author, the holder of the 00065 * economic rights, and the successive licensors have only limited 00066 * liability. 00067 * 00068 * In this respect, the user's attention is drawn to the risks associated 00069 * with loading, using, modifying and/or developing or reproducing the 00070 * software by the user in light of its specific status of free software, 00071 * that may mean that it is complicated to manipulate, and that also 00072 * therefore means that it is reserved for developers and experienced 00073 * professionals having in-depth computer knowledge. Users are therefore 00074 * encouraged to load and test the software's suitability as regards their 00075 * requirements in conditions enabling the security of their systems and/or 00076 * data to be ensured and, more generally, to use and operate it in the 00077 * same conditions as regards security. 00078 * 00079 * The fact that you are presently reading this means that you have had 00080 * knowledge of the CeCILL license and that you accept its terms. 00081 * 00082 */ 00083 00084 #ifndef _EXCEPTIONS_H_ 00085 #define _EXCEPTIONS_H_ 00086 00087 #include "ErrorCode.h" 00088 00089 #include <string> 00090 00091 using namespace treqs; 00096 class Error { 00097 public: 00098 Error() { 00099 } 00100 ; 00101 Error(ErrorCode errCode, std::string errMsg) { 00102 this->errCode = errCode; 00103 this->errMsg = errMsg; 00104 } 00105 ; 00106 ~Error() { 00107 } 00108 ; 00113 std::string getErrMsg() const{ 00114 return errMsg; 00115 } 00116 00121 ErrorCode getErrCode() const{ 00122 return errCode; 00123 } 00124 00129 void setErrMsg(std::string errMsg){ 00130 this->errMsg = errMsg; 00131 } 00132 00137 void setErrCode(ErrorCode errCode){ 00138 this->errCode = errCode; 00139 } 00140 00141 // TODO 00142 // std::String toString(){} 00143 00144 protected: 00146 std::string errMsg; 00148 ErrorCode errCode; 00149 }; 00150 00152 class ErrMySQL: public Error { 00153 }; 00154 00156 class ErrMySQLConnection: public ErrMySQL { 00157 }; 00158 00160 class ErrMySQLStatement: public ErrMySQL { 00161 }; 00162 00164 class ErrMySQLInitTable: public ErrMySQL { 00165 }; 00166 00167 class CopyError: public Error { 00168 }; 00169 00170 class UnknownCopyError: public CopyError { 00171 }; 00172 00173 class FileNotFoundError: public Error { 00174 public: 00175 FileNotFoundError() { 00176 } 00177 ; 00178 FileNotFoundError(std::string file){ 00179 path = file; 00180 } 00181 ; 00182 std::string getPath() { 00183 return path; 00184 } 00185 std::string getErrMsg(){ 00186 return errMsg + ":" + path; 00187 } 00188 void setPath(std::string path){ 00189 this->path = path; 00190 } 00191 private: 00192 std::string path; 00193 }; 00194 00196 class ConfigError: public Error { 00197 public: 00198 ConfigError() { 00199 } 00200 ; 00209 ConfigError(std::string S, std::string K, std::string V, std::string P) : 00210 section(S), key(K), value(V), path(P) { 00211 } 00212 ; 00213 00214 std::string getSection() { 00215 return section; 00216 } 00217 ; 00218 std::string getKey() { 00219 return key; 00220 } 00221 ; 00222 std::string getValue() { 00223 return value; 00224 } 00225 ; 00226 std::string getPath() { 00227 return path; 00228 } 00229 ; 00230 void setKey(std::string key) { 00231 this->key = key; 00232 } 00233 00234 void setPath(std::string path) { 00235 this->path = path; 00236 } 00237 00238 void setSection(std::string section) { 00239 this->section = section; 00240 } 00241 00242 void setValue(std::string value) { 00243 this->value = value; 00244 } 00245 00246 protected: 00247 std::string section; 00248 std::string key; 00249 std::string value; 00250 std::string path; 00251 }; 00252 00254 class ConfigNotFoundError: public ConfigError { 00255 public: 00256 std::string getErrMsg() { 00257 return section + "::" + key + " : Configuration item not found"; 00258 } 00259 }; 00260 00261 class MissingConfigError: public ConfigError { 00262 }; 00263 00265 class BadConfigError: public ConfigError { 00266 }; 00267 00268 class ControlerError: public Error { 00269 }; 00270 00271 class ControlerInsertError: public ControlerError { 00272 }; 00273 00274 class DuplicateFileException: public Error { 00275 }; 00276 00277 class DuplicateObjectException: public Error { 00278 }; 00279 00281 class NoFileRefException: public Error { 00282 }; 00283 00284 #endif