Exceptions.h

Go to the documentation of this file.
00001 //
00002 // Copyright (c) 2003-2005 greg Landrum and Rational Discovery LLC
00003 //
00004 //   @@ All Rights Reserved @@
00005 //  This file is part of the RDKit.
00006 //  The contents are covered by the terms of the BSD license
00007 //  which is included in the file license.txt, found at the root
00008 //  of the RDKit source tree.
00009 //
00010 #ifndef _RD_EXCEPTIONS_H
00011 #define _RD_EXCEPTIONS_H
00012 #include <exception>
00013 #include <string>
00014 
00015 //! \brief Class to allow us to throw an \c IndexError from C++ and have
00016 //!         it make it back to Python
00017 //!
00018 class IndexErrorException : public std::exception
00019 {
00020 public:
00021   IndexErrorException(int i) : _idx(i) {};
00022   int index () const { return _idx; };
00023   ~IndexErrorException () throw () {};
00024 private:
00025   int _idx;
00026 };
00027 
00028 //! \brief Class to allow us to throw a \c ValueError from C++ and have
00029 //!         it make it back to Python
00030 //!
00031 class ValueErrorException : public std::exception
00032 {
00033 public:
00034   ValueErrorException(const std::string i) : _value(i) {};
00035   ValueErrorException(const char *msg) : _value(msg) {};
00036   std::string message () const { return _value; };
00037   ~ValueErrorException () throw () {};
00038 private:
00039   std::string _value;
00040 };
00041 
00042 
00043 //! \brief Class to allow us to throw a \c KeyError from C++ and have
00044 //!         it make it back to Python
00045 //!
00046 class KeyErrorException : public std::exception
00047 {
00048 public:
00049   KeyErrorException(std::string key) : _key(key) {};
00050   std::string key() const { return _key; };
00051   ~KeyErrorException () throw () {};
00052 private:
00053   std::string _key;
00054 };
00055 
00056 #endif