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  public:
21  : std::runtime_error("IndexErrorException"), _idx(i){};
22  int index() const { return _idx; };
23  ~IndexErrorException() throw(){};
24 
25  private:
26  int _idx;
27 };
28 
29 //! \brief Class to allow us to throw a \c ValueError from C++ and have
30 //! it make it back to Python
31 //!
32 class ValueErrorException : public std::runtime_error {
33  public:
34  ValueErrorException(const std::string &i)
35  : std::runtime_error("ValueErrorException"), _value(i){};
36  ValueErrorException(const char *msg)
37  : std::runtime_error("ValueErrorException"), _value(msg){};
38  std::string message() const { return _value; };
39  ~ValueErrorException() throw(){};
40 
41  private:
42  std::string _value;
43 };
44 
45 //! \brief Class to allow us to throw a \c KeyError from C++ and have
46 //! it make it back to Python
47 //!
48 class KeyErrorException : public std::runtime_error {
49  public:
50  KeyErrorException(std::string key)
51  : std::runtime_error("KeyErrorException"), _key(key){};
52  std::string key() const { return _key; };
53  ~KeyErrorException() throw(){};
54 
55  private:
56  std::string _key;
57 };
58 
59 #endif
KeyErrorException(std::string key)
Definition: Exceptions.h:50
std::string message() const
Definition: Exceptions.h:38
STL namespace.
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
ValueErrorException(const std::string &i)
Definition: Exceptions.h:34
std::string key() const
Definition: Exceptions.h:52
Class to allow us to throw a ValueError from C++ and have it make it back to Python.
Definition: Exceptions.h:32
IndexErrorException(int i)
Definition: Exceptions.h:20
ValueErrorException(const char *msg)
Definition: Exceptions.h:36
Class to allow us to throw a KeyError from C++ and have it make it back to Python.
Definition: Exceptions.h:48