refactor: move xml_importer-specific exceptions into xml_importer

This is a minor refactoring in order to remove
a code dependency of ./xmodule on ./cms
This commit is contained in:
Kyle McCormick
2021-06-07 17:52:05 -04:00
parent c1e79c993e
commit 7a26ec6b92
5 changed files with 42 additions and 37 deletions

View File

@@ -1,45 +1,15 @@
"""
A common module for managing exceptions. Helps to avoid circular references
"""
from .errors import ERROR_WHILE_READING, FAILED_TO_IMPORT_MODULE
class CourseImportException(Exception):
"""Base exception class for course import workflows."""
def __init__(self):
super().__init__(self.description) # pylint: disable=no-member
class ErrorReadingFileException(CourseImportException):
"""
Raised when error occurs while trying to read a file.
"""
def __init__(self, filename, **kwargs):
self.description = ERROR_WHILE_READING.format(filename)
super().__init__(**kwargs)
class ModuleFailedToImport(CourseImportException):
"""
Raised when a module is failed to import.
"""
def __init__(self, display_name, location, **kwargs):
self.description = FAILED_TO_IMPORT_MODULE.format(display_name, location)
super().__init__(**kwargs)
class AssetNotFoundException(Exception):
"""
Raised when asset not found
"""
pass # lint-amnesty, pylint: disable=unnecessary-pass
class AssetSizeTooLargeException(Exception):
"""
Raised when the size of an uploaded asset exceeds the maximum size limit.
"""
pass # lint-amnesty, pylint: disable=unnecessary-pass