def safe_filter(error_output=u''):
 def inner(f):
  @wraps(f)
  def wrapper(*args, **kwargs):
   try:
    return f(*args, **kwargs)
   except Exception as err:
    if sorl_settings.THUMBNAIL_DEBUG:
     raise
    logger.error((u'Thumbnail filter failed: %s' % err.message), exc_info=sys.exc_info())
    return error_output
  return wrapper
 return inner

def safe_filter ( error_output = u'' ) : def inner ( f ) : @ wraps ( f ) def wrapper ( * args , ** kwargs ) : try : return f ( * args , ** kwargs ) except Exception as err : if sorl_settings . THUMBNAIL_DEBUG : raise logger . error ( ( u'Thumbnail filter failed: %s' % err . message ) , exc_info = sys . exc_info ( ) ) return error_output return wrapper return inner
a safe filter decorator only raising errors when thumbnail_debug is true otherwise returning error_output .