opmon/errors.py (15 lines of code) (raw):
"""Custom OpMon exception types."""
class OpmonException(Exception):
"""Exception thrown when an opmon project is invalid."""
def __init__(self, message):
"""Initialize exception."""
super().__init__(message)
class NoStartDateException(OpmonException):
"""Exception thrown when no start date has been defined."""
def __init__(self, slug, message="Project has no start date."):
"""Initialize exception."""
super().__init__(f"{slug} -> {message}")
class EndedException(OpmonException):
"""Exception thrown when the project has already ended."""
def __init__(self, slug, message="Project has already ended."):
"""Initialize exception."""
super().__init__(f"{slug} -> {message}")
class ConfigurationException(OpmonException):
"""Exception thrown when the configuration is incorrect."""
def __init__(self, slug, message="Project has been incorrectly configured."):
"""Initialize exception."""
super().__init__(f"{slug} -> {message}")
class StatisticNotImplementedForTypeException(OpmonException):
"""Exception thrown when statistic is not implemented for metric type."""
def __init__(self, slug, message="Statistic not implemented for metric type."):
"""Initialize exception."""
super().__init__(f"{slug} -> {message}")