IBR-DTNSuite  0.8
ibrcommon/ibrcommon/Exceptions.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2011 Johannes Morgenroth, IBR, TU Braunschweig
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef IBRCOMMON_EXCEPTIONS_H_
00018 #define IBRCOMMON_EXCEPTIONS_H_
00019 
00020 #include <stdexcept>
00021 #include <string>
00022 
00023 
00024 using namespace std;
00025 
00032 namespace ibrcommon
00033 {
00037         class Exception : public std::exception
00038         {
00039                 public:
00040                         Exception() throw()
00041                         {};
00042 
00043                         Exception(const exception&) throw()
00044                         {};
00045 
00046                         virtual ~Exception() throw()
00047                         {};
00048 
00053                         virtual const char* what() const throw()
00054                         {
00055                                 return _what.c_str();
00056                         }
00057 
00062                         Exception(string what) throw()
00063                         {
00064                                 _what = what;
00065                         };
00066 
00067                 protected:
00068                         string _what;
00069         };
00070 
00074         class NotImplementedException : public Exception
00075         {
00076         public:
00077                 NotImplementedException(string what = "This method isn't implemented.") throw() : Exception(what)
00078                 {
00079                 };
00080         };
00081 
00085         class IOException : public Exception
00086         {
00087         public:
00088                 IOException(string what = "Input/Output error.") throw() : Exception(what)
00089                 {
00090                 };
00091         };
00092 }
00093 
00094 #endif /*EXCEPTIONS_H_*/