"""Custom exceptions used in Interchange."""
[docs]class SMIRNOFFParameterAttributeNotImplementedError(Exception):
"""
Exception for when a parameter attribute is supported by the SMIRNOFF specification but not yet implemented.
For example, this was raised when k_bondorder (used in bond order-based interpolation of force constants)
before the behavior was supported.
"""
[docs]class SMIRNOFFHandlersNotImplementedError(Exception):
"""
Exception for when some parameter handlers in the SMIRNOFF specification are not implemented here.
"""
def __init__(self, *args):
if args:
if isinstance(args[0], str):
self.names = [args[0]]
elif isinstance(args[0], list):
self.names = args[0]
def __str__(self):
msg = "SMIRNOFF parameters not implemented here: "
for name in self.names:
msg += f"\t{name}"
return msg
[docs]class InvalidParameterHandlerError(ValueError):
"""
Generic exception for mismatch between expected and found ParameterHandler types.
"""
[docs]class InvalidBoxError(ValueError):
"""
Generic exception for errors reading box data.
"""
[docs]class InvalidTopologyError(ValueError):
"""
Generic exception for errors reading chemical topology data.
"""
[docs]class NonbondedEnergyError(AssertionError):
"""
Exception for when non-bonded energies computed from different objects differ.
"""
[docs]class InvalidExpressionError(ValueError):
"""
Exception for when an expression cannot safely be interpreted.
"""
[docs]class UnsupportedCutoffMethodError(BaseException):
"""
Exception for a cutoff method that is invalid or not supported by an engine.
"""
[docs]class UnimplementedCutoffMethodError(BaseException):
"""
Exception for a cutoff method that should be supported but it not yet implemented.
"""
[docs]class UnsupportedParameterError(ValueError):
"""
Exception for parameters having unsupported values, i.e. non-1.0 idivf.
"""
[docs]class UnsupportedBoxError(ValueError):
"""
Exception for processing an unsupported box, probably non-orthogonal.
"""
[docs]class UnsupportedExportError(BaseException):
"""
Exception for attempting to write to an unsupported file format.
"""
def __init__(self, *args):
if args:
self.file_ext = args[0]
def __str__(self):
if self.file_ext:
msg = f"Writing file format {self.file_ext} not supported."
else:
msg = "Writing unknown file format"
return msg
[docs]class MissingBoxError(BaseException):
"""
Exception for when box vectors are needed but missing.
"""
[docs]class MissingPositionsError(BaseException):
"""
Exception for when positions are needed but missing.
"""
[docs]class MissingParametersError(BaseException):
"""
Exception for when parameters are needed but missing.
"""
[docs]class MissingBondOrdersError(BaseException):
"""
Exception for when a parameter handler needs fractional bond orders but they are missing.
"""
[docs]class MissingUnitError(ValueError):
"""
Exception for data missing a unit tag.
"""
[docs]class UnitValidationError(ValueError):
"""
Exception for bad behavior when validating unit-tagged data.
"""
[docs]class NonbondedCompatibilityError(BaseException):
"""
Exception for unsupported combination of nonbonded methods.
"""
[docs]class MissingNonbondedCompatibilityError(BaseException):
"""
Exception for uncovered combination of nonbonded methods.
"""
[docs]class InternalInconsistencyError(BaseException):
"""
Fallback exception for bad behavior releating to a self-inconsistent internal state.
These should not be reached but are raised to safeguard against problematic edge cases silently passing.
"""
[docs]class SanderError(BaseException):
"""
Exception for when a sander subprocess fails.
"""
[docs]class GMXRunError(BaseException):
"""
Exception for when a GROMACS subprocess fails.
"""
[docs]class GMXGromppError(GMXRunError):
"""
Exception for when `gmx grompp` fails.
"""
[docs]class GMXMdrunError(GMXRunError):
"""
Exception for when `gmx mdrun` fails.
"""
[docs]class LAMMPSRunError(BaseException):
"""
Exception for when a LAMMPS subprocess fails.
"""
[docs]class EnergyError(BaseException):
"""
Base class for energies in reports not matching.
"""
[docs]class MissingEnergyError(BaseException):
"""
Exception for when one report has a value for an energy group but the other does not.
"""