[PATCH] Don't suppress error messages

Luke Macken lmacken at redhat.com
Tue Oct 28 17:07:28 UTC 2014


Looks good to me, +1

On Mon, Sep 29, 2014 at 04:54:55PM +0200, Mathieu Bridon wrote:
> If a failure occured when trying to create the cache folder, mash would
> just silently ignore the error and happily continue cranking along. It
> might of course fail later on, but the problem is impossible to debug if
> errors are silently suppressed.
> 
> However, if the error is merely that the directory already exists (as
> opposed to a permission issue, for example), then that is fine to
> ignore.
> 
> Likewise, if a failure occurs when trying to download, merely saying
> "can't download" is not helpful. Adding the actual error message makes
> it easier to figure out what went wrong.
> ---
>  mash/__init__.py | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/mash/__init__.py b/mash/__init__.py
> index 566b8c1..27cdc47 100644
> --- a/mash/__init__.py
> +++ b/mash/__init__.py
> @@ -12,6 +12,7 @@
>  # with this program; if not, write to the Free Software Foundation, Inc.,
>  # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
>  
> +import errno
>  import glob
>  import os
>  import logging
> @@ -269,8 +270,11 @@ class Mash:
>                      path = os.path.join(koji.pathinfo.build(builds_hash[pkg['build_id']]), koji.pathinfo.rpm(pkg))
>                  try:
>                      os.mkdir(os.path.dirname(cachepath))
> -                except:
> -                    pass
> +                except Exception as e:
> +                    if e.errno != errno.EEXIST:
> +                        # If the directory already exists, that's fine
> +                        self.logger.error(e)
> +
>                  try:
>                      result = urlgrabber.grabber.urlgrab(path, cachepath)
>                  except:
> @@ -279,8 +283,9 @@ class Mash:
>                      path = os.path.join(koji.pathinfo.build(builds_hash[pkg['build_id']]), koji.pathinfo.rpm(pkg))
>                      try:
>                          result = urlgrabber.grabber.urlgrab(path, cachepath)
> -                    except:
> -                        self.logger.error("ERROR: can't download %s from %s" % (nevra(pkg), path))
> +                    except Exception as e:
> +                        self.logger.error("ERROR: can't download %s from %s: %s"
> +                                          % (nevra(pkg), path, e))
>                          return None
>  
>              fd = open(result)
> -- 
> 2.1.0
> 
> _______________________________________________
> rel-eng mailing list
> rel-eng at lists.fedoraproject.org
> https://admin.fedoraproject.org/mailman/listinfo/rel-eng


More information about the rel-eng mailing list