RDKit
Open-source cheminformatics and machine learning.
Exceptions.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2003-2005 greg Landrum and Rational Discovery LLC
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 #ifndef _RD_EXCEPTIONS_H
11 #define _RD_EXCEPTIONS_H
12 #include <stdexcept>
13 #include <string>
14 
15 //! \brief Class to allow us to throw an \c IndexError from C++ and have
16 //! it make it back to Python
17 //!
18 class IndexErrorException : public std::runtime_error
19 {
20 public:
21  IndexErrorException(int i) : std::runtime_error("IndexErrorException"),_idx(i) {};
22  int index () const { return _idx; };
23  ~IndexErrorException () throw () {};
24 private:
25  int _idx;
26 };
27 
28 //! \brief Class to allow us to throw a \c ValueError from C++ and have
29 //! it make it back to Python
30 //!
31 class ValueErrorException : public std::runtime_error
32 {
33 public:
34  ValueErrorException(const std::string i) : std::runtime_error("ValueErrorException"), _value(i) {};
35  ValueErrorException(const char *msg) : std::runtime_error("ValueErrorException"), _value(msg) {};
36  std::string message () const { return _value; };
37  ~ValueErrorException () throw () {};
38 private:
39  std::string _value;
40 };
41 
42 
43 //! \brief Class to allow us to throw a \c KeyError from C++ and have
44 //! it make it back to Python
45 //!
46 class KeyErrorException : public std::runtime_error
47 {
48 public:
49  KeyErrorException(std::string key) : std::runtime_error("KeyErrorException"), _key(key) {};
50  std::string key() const { return _key; };
51  ~KeyErrorException () throw () {};
52 private:
53  std::string _key;
54 };
55 
56 #endif
KeyErrorException(std::string key)
Definition: Exceptions.h:49
std::string message() const
Definition: Exceptions.h:36
STL namespace.
ValueErrorException(const std::string i)
Definition: Exceptions.h:34
int index() const
Definition: Exceptions.h:22
Class to allow us to throw an IndexError from C++ and have it make it back to Python.
Definition: Exceptions.h:18
std::string key() const
Definition: Exceptions.h:50
Class to allow us to throw a ValueError from C++ and have it make it back to Python.
Definition: Exceptions.h:31
IndexErrorException(int i)
Definition: Exceptions.h:21
ValueErrorException(const char *msg)
Definition: Exceptions.h:35
Class to allow us to throw a KeyError from C++ and have it make it back to Python.
Definition: Exceptions.h:46