errors.py 1.36 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
"""All Error Types pertaining to Enrollment."""


class CourseEnrollmentError(Exception):
    """Generic Course Enrollment Error.

    Describes any error that may occur when reading or updating enrollment information for a user or a course.

    """
    def __init__(self, msg, data=None):
        super(CourseEnrollmentError, self).__init__(msg)
        # Corresponding information to help resolve the error.
        self.data = data


class CourseNotFoundError(CourseEnrollmentError):
    pass


class UserNotFoundError(CourseEnrollmentError):
    pass


class CourseEnrollmentClosedError(CourseEnrollmentError):
    pass


class CourseEnrollmentFullError(CourseEnrollmentError):
    pass


class CourseEnrollmentExistsError(CourseEnrollmentError):
33 34 35 36 37
    enrollment = None

    def __init__(self, message, enrollment):
        super(CourseEnrollmentExistsError, self).__init__(message)
        self.enrollment = enrollment
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52


class CourseModeNotFoundError(CourseEnrollmentError):
    """The requested course mode could not be found."""
    pass


class EnrollmentNotFoundError(CourseEnrollmentError):
    """The requested enrollment could not be found."""
    pass


class EnrollmentApiLoadError(CourseEnrollmentError):
    """The data API could not be loaded."""
    pass
53 54 55 56 57


class InvalidEnrollmentAttribute(CourseEnrollmentError):
    """Enrollment Attributes could not be validated"""
    pass