00001 /************************************************************************************************** 00002 * LibNeural++ v.0.4 - All-purpose library for managing neural networks * 00003 * Copyright (C) 2009, BlackLight * 00004 * * 00005 * This program is free software: you can redistribute it and/or modify it under the terms of the * 00006 * GNU General Public License as published by the Free Software Foundation, either version 3 of * 00007 * the License, or (at your option) any later version. This program is distributed in the hope * 00008 * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * 00009 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * 00010 * more details. You should have received a copy of the GNU General Public License along with * 00011 * this program. If not, see <http://www.gnu.org/licenses/>. * 00012 **************************************************************************************************/ 00013 00014 #ifndef __NEURALPP_EXCEPTION 00015 #define __NEURALPP_EXCEPTION 00016 00017 #include <cstdio> 00018 #include <cstring> 00019 #include <exception> 00020 00021 namespace neuralpp { 00026 class NetworkFileNotFoundException : public std::exception { 00027 public: 00028 NetworkFileNotFoundException() {} 00029 const char* what() const throw() { return "Attempt to load a neural network from an invalid network file"; } 00030 }; 00031 00037 class NetworkFileWriteException : public std::exception { 00038 public: 00039 NetworkFileWriteException() {} 00040 const char* what() const throw() { return "There was an error while writing the network file"; } 00041 }; 00042 00047 class InvalidXMLException : public std::exception { 00048 char *error; 00049 00050 public: 00051 InvalidXMLException(const char *err = " ") { 00052 error = new char[strlen(err)+40]; 00053 sprintf (error, "Attempt to load an invalid XML file: %s", err); 00054 } 00055 00056 const char* what() const throw() { return error; } 00057 }; 00058 00064 class NetworkIndexOutOfBoundsException : public std::exception { 00065 public: 00066 NetworkIndexOutOfBoundsException() {} 00067 const char* what() const throw() { return "Attempt to access a non-existing neuron"; } 00068 }; 00069 00075 class InvalidSynapticalWeightException : public std::exception { 00076 public: 00077 InvalidSynapticalWeightException() {} 00078 const char* what() const throw() { return "Attempt to set an invalid weight for the synapsis"; } 00079 }; 00080 } 00081 00082 #endif 00083