From 76cb0035e4928cf7f6c32e239cd35515c0a92161 Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Mon, 4 Jan 2010 14:17:45 -0800 Subject: Add a custom error class This makes it easier to catch errors in the calling tools. They won't have to know about the internals of the library, just catch the custom error and deal with it. --- src/fedpkg/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/fedpkg/__init__.py b/src/fedpkg/__init__.py index ceffbbc..17ea192 100644 --- a/src/fedpkg/__init__.py +++ b/src/fedpkg/__init__.py @@ -19,6 +19,10 @@ LOOKASIDE = 'http://cvs.fedoraproject.org/repo/pkgs' LOOKASIDEHASH = 'md5' GITBASEURL = 'ssh://%(user)s@pkgs.stg.fedoraproject.org/%(module)s' +# Define our own error class +class FedpkgError(Exception): + pass + # Define some helper functions, they start with _ def _hash_file(file, hashtype): """Return the hash of a file given a hash type""" @@ -187,7 +191,7 @@ class PackageModule: os.uname()[4]) if not os.path.exists(os.path.join(self.path, srpm)) and not \ os.path.exists(os.path.join(self.path, rpm)): - return "Need to build srpm and rpm first" + raise FedpkgError("Need to build srpm and rpm first") cmd = ['rpmlint', os.path.join(self.path, srpm), os.path.join(self.path, rpm)] output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate() -- cgit