Fix typo.
[alexxy/gromacs.git] / python_packaging / src / gmxapi / exceptions.py
1 #
2 # This file is part of the GROMACS molecular simulation package.
3 #
4 # Copyright (c) 2019, by the GROMACS development team, led by
5 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 # and including many others, as listed in the AUTHORS file in the
7 # top-level source directory and at http://www.gromacs.org.
8 #
9 # GROMACS is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public License
11 # as published by the Free Software Foundation; either version 2.1
12 # of the License, or (at your option) any later version.
13 #
14 # GROMACS is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 # Lesser General Public License for more details.
18 #
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with GROMACS; if not, see
21 # http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23 #
24 # If you want to redistribute modifications to GROMACS, please
25 # consider that scientific software is very special. Version
26 # control is crucial - bugs must be traceable. We will be happy to
27 # consider code for inclusion in the official distribution, but
28 # derived work must not be called official GROMACS. Details are found
29 # in the README & COPYING files - if they are missing, get the
30 # official version at http://www.gromacs.org.
31 #
32 # To help us fund GROMACS development, we humbly ask that you cite
33 # the research papers on the package. Check out http://www.gromacs.org.
34
35 """
36 Exceptions and Warnings raised by gmxapi module operations.
37
38 Errors, warnings, and other exceptions used in the GROMACS
39 Python package are defined in the `exceptions` submodule.
40
41 The gmxapi Python package defines a root exception,
42 exceptions.Error, from which all Exceptions thrown from
43 within the module should derive. If a published component of
44 the gmxapi package throws an exception that cannot be caught
45 as a gmxapi.exceptions.Error, please report the bug.
46 """
47
48 __all__ = ['ApiError',
49            'DataShapeError',
50            'Error',
51            'FeatureNotAvailableError',
52            'NotImplementedError',
53            'ProtocolError',
54            'TypeError',
55            'UsageError',
56            'ValueError',
57            'Warning'
58            ]
59
60
61 class Error(Exception):
62     """Base exception for gmx.exceptions classes."""
63
64
65 class Warning(Warning):
66     """Base warning class for gmx.exceptions."""
67
68
69 class ApiError(Error):
70     """An API operation was attempted with an incompatible object."""
71
72
73 class DataShapeError(Error):
74     """An object has an incompatible shape.
75
76     This exception does not imply that the Type or any other aspect of the data
77     has been checked.
78     """
79
80
81 class NotImplementedError(Error):
82     """Specified feature is not implemented in the current code.
83
84     This exception indicates that the implemented code does not support the
85     API as specified. The calling code has used valid syntax, as documented for
86     the API, but has reached incompletely implemented code, which should be
87     considered a bug.
88     """
89     # May be useful for error checking in base classes or as a development tool
90     # to avoid releasing incomplete implementations (e.g. overlooked "To do"s)
91
92
93 class FeatureNotAvailableError(Error):
94     """Requested feature not available in the current environment.
95
96     This exception will usually indicate an issue with the user's environment or
97     run time details. There may be a missing optional dependency, which should
98     be specified in the exception message.
99     """
100
101
102 class ProtocolError(Error):
103     """Unexpected API behavior or protocol violation.
104
105     This exception generally indicates a gmxapi bug, since it should only
106     occur through incorrect assumptions or misuse of API implementation internals.
107     """
108
109
110 class TypeError(Error):
111     """Incompatible type for gmxapi data.
112
113     Reference datamodel.rst for more on gmxapi data typing.
114     """
115
116
117 class UsageError(Error):
118     """Unsupported syntax or call signatures.
119
120     Generic usage error for gmxapi module.
121     """
122
123
124 class ValueError(Error):
125     """A user-provided value cannot be interpreted or doesn't make sense."""