00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef TOOLS_EXCEPTIONS_H
00022 #define TOOLS_EXCEPTIONS_H
00023
00024 #include <exception>
00025 #include <string>
00026 #include <sstream>
00027 #include "tools.h"
00028 using namespace std;
00036 class InterpolationError : public exception {
00037 public:
00044 InterpolationError(const string &src_file, const int src_line, const string &msg): src_file(src_file),src_line(src_line),msg(msg){};
00045 ~InterpolationError() throw() {}
00046 ;
00047 virtual const char* what() const throw() {
00048 std::ostringstream oss;
00049 oss<<src_file<<"("<<src_line<<")"<<" InterpolationError : "<<msg<<endl;
00050 return oss.str().c_str();
00051 };
00052 private:
00053 string src_file;
00054 int src_line;
00055 string msg;
00056 };
00057
00061 class out_of_bound : public std::exception {
00062 public:
00063 out_of_bound(const int index, const int size):index(index),size(size) {};
00064 ~out_of_bound() throw() {}
00065 ;
00066 virtual const char* what() const throw() {
00067 std::ostringstream oss;
00068 oss<<"out_of_bound : the index "<<index<<" is out of bound. It must be in the range [0,"<<size<<"["<<std::endl;
00069 return oss.str().c_str();
00070 };
00071 private:
00072 int index;
00073 int size;
00074 };
00075
00076 #endif