Source code for nider.exceptions

[docs]class ImageGeneratorException(Exception): '''Base class for exceptions raised by nider'''
[docs]class ImageGeneratorWarning(Warning): '''Base class for warnings raised by nider'''
[docs]class InvalidAlignException(ImageGeneratorException): '''Exception raised when align is not supported by nider''' def __init__(self, align_provided, available_aligns=None): if available_aligns is None: available_aligns = ['center', 'right', 'left'] available_aligns_str = ' or '.join(available_aligns) super().__init__( "Align has to be set either to {}. You provided '{}'".format(available_aligns_str, align_provided))
[docs]class FontNotFoundWarning(ImageGeneratorWarning): '''Warning raised when font cannot be found''' def __init__(self, fontpath_provided): super().__init__( "Font {} hasn't been found. Default font has been set instead".format(fontpath_provided))
[docs]class FontNotFoundException(ImageGeneratorWarning): '''Exception raised when font cannot be found''' def __init__(self, fontpath_provided): super().__init__( "Font {} hasn't been found.".format(fontpath_provided))
[docs]class DefaultFontWarning(ImageGeneratorWarning): '''Warning raised when default font was used''' def __init__(self): super().__init__( "Font hasn't been provided. Default font has been set instead")
[docs]class ImageSizeFixedWarning(ImageGeneratorWarning): '''Warning raised when the size of the image has to be adjusted to the provided content's size because the content takes much space''' def __init__(self): super().__init__( "Image size has been adjusted to the provided content size because the content took too much space")
[docs]class AutoGeneratedUnitColorUsedWarning(ImageGeneratorWarning): '''Warning raised when auto generated unit color was used''' def __init__(self, unit, color_used): super().__init__( "You didn't provide a color for {}. Auto generated one('{}') has been used".format(unit.__class__.__name__, color_used))
[docs]class AutoGeneratedUnitOutlinecolorUsedWarning(ImageGeneratorWarning): '''Warning raised when auto generated unit's outline color was used''' def __init__(self, unit, color_used): super().__init__( "You didn't provide an outline color for {}. Auto generated one('{}') has been used".format(unit.__class__.__name__, color_used))