          if raise_error:
              raise Exception(msg)
      except ValueError:
          success = False
          msg = ("Error while reading image. This is most likely caused by special characters in "
                 "the filename: '{}'".format(filename))
          logger.error(msg)
          if raise_error:
              raise Exception(msg)
      except Exception as err:  # pylint:disable=broad-except
          success = False
 
</s> remove     except ValueError:
 </s> add     except ValueError as err: </s> remove             raise ValueError
    except TypeError:
 </s> add             raise ValueError("Image is None")
    except TypeError as err:
        msg = ("Error while reading image. This can be caused by special characters in the "
               "filename or a corrupt image file: '{}'".format(filename))
        msg += ". Original error message: {}".format(str(err))
          if raise_error:
              raise Exception(msg)
      except ValueError:
          success = False
        msg = ("Error while reading image. This can be caused by special characters in the "
               "filename or a corrupt image file: '{}'".format(filename))
        msg += ". Original error message: {}".format(str(err))
        msg = ("Error while reading image. This can be caused by special characters in the "
               "filename or a corrupt image file: '{}'".format(filename))
        msg += ". Original error message: {}".format(str(err))
          logger.error(msg)
          if raise_error:
              raise Exception(msg)
      except Exception as err:  # pylint:disable=broad-except
          success = False
keep keep keep keep replace replace keep keep keep keep keep
 lib.image - More information on image read errors 
lib/image.py