00001 /**************************************************************** 00002 * 00003 * Copyright (c) 2011 00004 * All rights reserved. 00005 * 00006 * Hochschule Bonn-Rhein-Sieg 00007 * University of Applied Sciences 00008 * Computer Science Department 00009 * 00010 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00011 * 00012 * Author: 00013 * Jan Paulus, Nico Hochgeschwender, Michael Reckhaus, Azamat Shakhimardanov 00014 * Supervised by: 00015 * Gerhard K. Kraetzschmar 00016 * 00017 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00018 * 00019 * This sofware is published under a dual-license: GNU Lesser General Public 00020 * License LGPL 2.1 and BSD license. The dual-license implies that users of this 00021 * code may choose which terms they prefer. 00022 * 00023 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00024 * 00025 * Redistribution and use in source and binary forms, with or without 00026 * modification, are permitted provided that the following conditions are met: 00027 * 00028 * * Redistributions of source code must retain the above copyright 00029 * notice, this list of conditions and the following disclaimer. 00030 * * Redistributions in binary form must reproduce the above copyright 00031 * notice, this list of conditions and the following disclaimer in the 00032 * documentation and/or other materials provided with the distribution. 00033 * * Neither the name of the Hochschule Bonn-Rhein-Sieg nor the names of its 00034 * contributors may be used to endorse or promote products derived from 00035 * this software without specific prior written permission. 00036 * 00037 * This program is free software: you can redistribute it and/or modify 00038 * it under the terms of the GNU Lesser General Public License LGPL as 00039 * published by the Free Software Foundation, either version 2.1 of the 00040 * License, or (at your option) any later version or the BSD license. 00041 * 00042 * This program is distributed in the hope that it will be useful, 00043 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00044 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00045 * GNU Lesser General Public License LGPL and the BSD license for more details. 00046 * 00047 * You should have received a copy of the GNU Lesser General Public 00048 * License LGPL and BSD license along with this program. 00049 * 00050 ****************************************************************/ 00051 00052 #ifndef _EXCEPTIONS_HPP 00053 #define _EXCEPTIONS_HPP 00054 00055 00056 #include <exception> 00057 #include <stdexcept> 00058 #include <iostream> 00059 #include <string> 00060 00061 using namespace std; 00062 namespace youbot { 00063 00064 /// File not found exception 00065 class FileNotFoundException : public std::ios_base::failure { 00066 string msg; 00067 00068 public: 00069 // Takes a character string describing the error. 00070 explicit FileNotFoundException(const string& message) throw () 00071 :std::ios_base::failure(message) { 00072 msg = message + " file not found" ; 00073 }; 00074 00075 virtual ~FileNotFoundException() throw () { 00076 }; 00077 00078 // Returns a C-style character string describing the general cause of the current error 00079 virtual const char* what() const throw () { 00080 return msg.c_str(); 00081 }; 00082 }; 00083 00084 /// Key in configuration file not found exception 00085 class KeyNotFoundException : public std::ios_base::failure { 00086 string msg; 00087 00088 public: 00089 // Takes a character string describing the error. 00090 explicit KeyNotFoundException(const string& message) throw () 00091 :std::ios_base::failure(message) { 00092 msg = message + " key in config file not found" ; 00093 }; 00094 00095 virtual ~KeyNotFoundException() throw () { 00096 }; 00097 00098 // Returns a C-style character string describing the general cause of the current error 00099 virtual const char* what() const throw () { 00100 return msg.c_str(); 00101 }; 00102 }; 00103 /// Joint parameter exception 00104 class JointParameterException : public std::runtime_error { 00105 string msg; 00106 00107 public: 00108 // Takes a character string describing the error. 00109 explicit JointParameterException(const string& message) throw() 00110 : std::runtime_error(message) { 00111 msg = message; 00112 }; 00113 00114 virtual ~JointParameterException() throw () { 00115 }; 00116 00117 // Returns a C-style character string describing the general cause of the current error 00118 virtual const char* what() const throw () { 00119 return msg.c_str(); 00120 }; 00121 }; 00122 /// Joint error exception 00123 class JointErrorException : public std::runtime_error { 00124 string msg; 00125 00126 public: 00127 // Takes a character string describing the error. 00128 explicit JointErrorException(const string& message) throw () 00129 :std::runtime_error(message) { 00130 msg = message; 00131 }; 00132 00133 virtual ~JointErrorException() throw () { 00134 }; 00135 00136 // Returns a C-style character string describing the general cause of the current error 00137 virtual const char* what() const throw () { 00138 return msg.c_str(); 00139 }; 00140 }; 00141 /// EtherCAT Connection Error 00142 class EtherCATConnectionException : public std::runtime_error { 00143 string msg; 00144 00145 public: 00146 // Takes a character string describing the error. 00147 explicit EtherCATConnectionException(const string& message) throw () 00148 :std::runtime_error(message) { 00149 msg = message; 00150 }; 00151 00152 virtual ~EtherCATConnectionException() throw () { 00153 }; 00154 00155 // Returns a C-style character string describing the general cause of the current error 00156 virtual const char* what() const throw () { 00157 return msg.c_str(); 00158 }; 00159 }; 00160 00161 00162 00163 00164 00165 } // namespace youbot 00166 #endif //_EXCEPTIONS_HPP