Scine::Swoose  2.1.0
This is the SCINE module Swoose.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
MMExceptions.h
Go to the documentation of this file.
1 
8 #ifndef MOLECULARMECHANICS_MMEXCEPTIONS_H
9 #define MOLECULARMECHANICS_MMEXCEPTIONS_H
10 
11 #include <exception>
12 #include <stdexcept>
13 #include <string>
14 
15 /*
16  * Defining own exceptions for molecular mechanics.
17  */
18 
19 namespace Scine {
20 namespace MolecularMechanics {
21 
22 class MMBondParametersNotAvailableException : public std::exception {
23  public:
24  explicit MMBondParametersNotAvailableException(const std::string& atom1, const std::string& atom2) {
25  message_ = "No bond parameters for " + atom1 + "-" + atom2;
26  }
27 
28  const char* what() const noexcept override {
29  return message_.c_str();
30  }
31 
32  private:
33  std::string message_;
34 };
35 
36 class MMAngleParametersNotAvailableException : public std::exception {
37  public:
38  explicit MMAngleParametersNotAvailableException(const std::string& atom1, const std::string& atom2, const std::string& atom3) {
39  message_ = "No angle parameters for " + atom1 + "-" + atom2 + "-" + atom3;
40  }
41 
42  const char* what() const noexcept override {
43  return message_.c_str();
44  }
45 
46  private:
47  std::string message_;
48 };
49 
50 class MMDihedralParametersNotAvailableException : public std::exception {
51  public:
52  explicit MMDihedralParametersNotAvailableException(const std::string& atom1, const std::string& atom2,
53  const std::string& atom3, const std::string& atom4) {
54  message_ = "No dihedral parameters for " + atom1 + "-" + atom2 + "-" + atom3 + "-" + atom4;
55  }
56 
57  const char* what() const noexcept override {
58  return message_.c_str();
59  }
60 
61  private:
62  std::string message_;
63 };
64 
66  public:
67  explicit MMImproperDihedralParametersNotAvailableException(const std::string& atomCentral, const std::string& atom2,
68  const std::string& atom3, const std::string& atom4) {
69  message_ = "No improper dihedral parameters for " + atomCentral + "-" + atom2 + "-" + atom3 + "-" + atom4;
70  }
71 
72  const char* what() const noexcept override {
73  return message_.c_str();
74  }
75 
76  private:
77  std::string message_;
78 };
79 
80 class MMLjParametersNotAvailableException : public std::exception {
81  public:
82  explicit MMLjParametersNotAvailableException(const std::string& atomType) {
83  message_ = "There are no Lennard Jones (vdW) parameters for " + atomType;
84  }
85 
86  const char* what() const noexcept override {
87  return message_.c_str();
88  }
89 
90  private:
91  std::string message_;
92 };
93 
94 class ElementTypeIsNotAllowedForHydrogenBondsException : public std::runtime_error {
95  public:
96  explicit ElementTypeIsNotAllowedForHydrogenBondsException(const std::string& s) : runtime_error(s) {
97  }
98 };
99 
100 class TwoResultsForHydrogenBondsAreNotEqualException : public std::runtime_error {
101  public:
102  explicit TwoResultsForHydrogenBondsAreNotEqualException(const std::string& s) : runtime_error(s) {
103  }
104 };
105 
106 } // namespace MolecularMechanics
107 } // namespace Scine
108 
109 #endif // MOLECULARMECHANICS_MMEXCEPTIONS_H