pytex/errors/errors.py

66 lines
2.3 KiB
Python

class PyTexError(Exception):
def __init__(self, message, *args, **kwargs):
self.message = message
def __str__(self):
return r'{prefix} ERROR: {message}'.format(
prefix='[PyTeX]',
message=self.message
)
class SubmoduleDirtyForbiddenError(PyTexError):
def __init__(self):
super().__init__(
"Submodule PyTeX is dirty, but writing dirty files is not allowed. "
"Call PyTeX with '--allow-dirty' option, or commit the submodule changes.")
class ExtraHeaderFileNotFoundError(PyTexError):
def __init__(self):
super().__init__('Path to extra header content is invalid.')
class ProgrammingError(PyTexError):
def __init__(self):
super().__init__("A FATAL programming error has occurred. Please contact the developer.")
class UnknownTexVersionError(PyTexError):
def __init__(self, tex_version: str):
super().__init__(
f"Unknown TeX version {tex_version}given. Only 'LaTeX2e' and 'LaTeX3' "
f"are currently supported"
)
class ModifiedFileInBuildDirectoryError(PyTexError):
def __init__(self, filename: str):
super().__init__(
f"File '{filename}' in the build directory has been modified since the last build. "
f"Refusing to overwrite a modified file, since you could lose your manual changes. "
f"If you are sure you do not need this anymore, delete it manually and build again. "
f"Note that for exactly this reason, it is strongly discouraged to edit built files directly."
)
class UnknownFileInBuildDirectoryNoOverwriteError(PyTexError):
def __init__(self, filename: str):
super().__init__(
f"Unknown file {filename} in build directory found. "
f"PyTeX has no knowledge whether this file has been built by PyTeX. "
f"Refusing to overwrite this file, since you could lose your data. "
f"If you are sure, this can be got rid of, delete the file manually, "
f"and run the build again."
)
class UnknownFileInBuildDirectory(PyTexError):
def __init__(self, filename):
super().__init__(
f"Detected unknown file {filename} in build directory."
f"PyTeX has no knowledge about this, you should probably"
f"remove it."
)