Source code for landlab.field.errors
[docs]
class Error(Exception):
"""Base class for errors in this module."""
[docs]
class FieldError(Error, KeyError):
"""Raise this error for a missing field name."""
[docs]
class GroupError(Error, KeyError):
"""Raise this error for a missing group name."""
[docs]
class GroupSizeError(Error, KeyError):
"""Raise this error if a group has changed sizes."""
[docs]
def __init__(self, group, old_size, new_size):
super().__init__(group, old_size, new_size)
def __str__(self):
group, old_size, new_size = self.args
return (
f"number of {group} elements has changed."
f" (was = {old_size}, now={new_size})"
)