You are viewing the latest unreleased documentation v3.2.2.dev178. You may prefer a stable version.

Source code for iris.exceptions

# Copyright Iris contributors
#
# This file is part of Iris and is released under the LGPL license.
# See COPYING and COPYING.LESSER in the root of the repository for full
# licensing details.
"""
Exceptions specific to the Iris package.

"""


[docs]class IrisError(Exception): """Base class for errors in the Iris package.""" pass
[docs]class CoordinateCollapseError(IrisError): """Raised when a requested coordinate cannot be collapsed.""" pass
[docs]class CoordinateNotFoundError(KeyError): """Raised when a search yields no coordinates.""" pass
[docs]class CellMeasureNotFoundError(KeyError): """Raised when a search yields no cell measures.""" pass
[docs]class AncillaryVariableNotFoundError(KeyError): """Raised when a search yields no ancillary variables.""" pass
[docs]class ConnectivityNotFoundError(KeyError): """Raised when a search yields no connectivities.""" pass
[docs]class CoordinateMultiDimError(ValueError): """Raised when a routine doesn't support multi-dimensional coordinates.""" def __init__(self, msg): # N.B. deferred import to avoid a circular import dependency. import iris.coords if isinstance(msg, iris.coords.Coord): fmt = "Multi-dimensional coordinate not supported: '%s'" msg = fmt % msg.name() ValueError.__init__(self, msg)
[docs]class CoordinateNotRegularError(ValueError): """Raised when a coordinate is unexpectedly irregular.""" pass
[docs]class InvalidCubeError(IrisError): """Raised when a Cube validation check fails.""" pass
[docs]class ConstraintMismatchError(IrisError): """ Raised when a constraint operation has failed to find the correct number of results. """ pass
[docs]class NotYetImplementedError(IrisError): """ Raised by missing functionality. Different meaning to NotImplementedError, which is for abstract methods. """ pass
[docs]class TranslationError(IrisError): """Raised when Iris is unable to translate format-specific codes.""" pass
[docs]class IgnoreCubeException(IrisError): """ Raised from a callback function when a cube should be ignored on load. """ pass
[docs]class ConcatenateError(IrisError): """ Raised when concatenate is expected to produce a single cube, but fails to do so. """ def __init__(self, differences): """ Creates a ConcatenateError with a list of textual descriptions of the differences which prevented a concatenate. Args: * differences: The list of strings which describe the differences. """ self.differences = differences def __str__(self): return "\n ".join( ["failed to concatenate into a single cube."] + list(self.differences) )
[docs]class MergeError(IrisError): """ Raised when merge is expected to produce a single cube, but fails to do so. """ def __init__(self, differences): """ Creates a MergeError with a list of textual descriptions of the differences which prevented a merge. Args: * differences: The list of strings which describe the differences. """ self.differences = differences def __str__(self): return "\n ".join( ["failed to merge into a single cube."] + list(self.differences) )
[docs]class DuplicateDataError(MergeError): """Raised when merging two or more cubes that have identical metadata.""" def __init__(self, msg): self.differences = [msg]
[docs]class LazyAggregatorError(Exception): pass
[docs]class UnitConversionError(IrisError): """Raised when Iris is unable to convert a unit.""" pass