Skip to content

Commit

Permalink
Merge pull request #213 from ecmwf/polytope-error
Browse files Browse the repository at this point in the history
create base polytope error
  • Loading branch information
mathleur authored Sep 18, 2024
2 parents 4d46064 + e0a33d0 commit eea882c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions polytope/utility/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
class AxisOverdefinedError(KeyError):
class PolytopeError(Exception):
pass


class AxisOverdefinedError(PolytopeError, KeyError):
def __init__(self, axis):
self.axis = axis
self.message = (
Expand All @@ -7,19 +11,19 @@ def __init__(self, axis):
)


class AxisUnderdefinedError(KeyError):
class AxisUnderdefinedError(PolytopeError, KeyError):
def __init__(self, axis):
self.axis = axis
self.message = f"Axis {axis} is underdefined. It does not appear in any input polytope."


class AxisNotFoundError(KeyError):
class AxisNotFoundError(PolytopeError, KeyError):
def __init__(self, axis):
self.axis = axis
self.message = f"Axis {axis} does not exist in the datacube."


class UnsliceableShapeError(KeyError):
class UnsliceableShapeError(PolytopeError, KeyError):
def __init__(self, axis):
self.axis = axis
self.message = f"Higher-dimensional shape does not support unsliceable axis {axis.name}."

0 comments on commit eea882c

Please sign in to comment.