redbrick/useradm

View on GitHub
useradm/rberror.py

Summary

Maintainability
A
0 mins
Test Coverage
# --------------------------------------------------------------------------- #
# MODULE DESCRIPTION                                                          #
# --------------------------------------------------------------------------- #
"""RedBrick Error Module; contains RedBrick exception classes."""

# --------------------------------------------------------------------------- #
# DATA                                                                        #
# --------------------------------------------------------------------------- #

__version__ = '$Revision: 1.2 $'
__author__ = 'Cillian Sharkey'

# --------------------------------------------------------------------------- #
# CLASSES                                                                     #
# --------------------------------------------------------------------------- #


class RBError(Exception):
    """Base class for RedBrick exceptions"""

    def __init__(self, mesg):
        """Create new RBError object with given error message."""
        super(RBError, self).__init__(mesg)
        self.mesg = mesg

    def __str__(self):
        """Return exception error message."""

        return "ERROR: %s" % self.mesg


class RBFatalError(RBError):
    """Class for fatal RedBrick exceptions"""

    def __str__(self):
        """Return exception error message."""

        return "FATAL: %s" % self.mesg


class RBWarningError(RBError):
    """Class for warning RedBrick exceptions. These can be overrided."""

    def __str__(self):
        """Return exception error message."""

        return "WARNING: %s" % self.mesg