Unverified Commit 14a8d2b0 authored by Andrej Shadura's avatar Andrej Shadura
Browse files

Use better-suitable exceptions in error cases



Signed-off-by: Andrej Shadura's avatarAndrej Shadura <andrew.shadura@collabora.co.uk>
parent c729a2ed
......@@ -6,6 +6,7 @@ import os
import osc.cmdln as cmdln
import osc.conf as conf
import osc.core
from osc.oscerr import WrongArgs, OscIOError
from debian.deb822 import Changes, Dsc
from tempfile import TemporaryDirectory
......@@ -27,7 +28,7 @@ def get_objects_from_file(filename):
changes = Changes(f)
if 'source' not in changes['architecture'].split():
raise Exception(filename + ' does not contain source code')
raise WrongArgs(filename + ' does not contain source code')
for rec in changes['files']:
if rec['name'].endswith('.dsc'):
......@@ -36,15 +37,17 @@ def get_objects_from_file(filename):
dsc = Dsc(fdsc)
return changes, dsc, dscfile
else:
raise Exception(filename + ' does not list a .dsc file')
raise WrongArgs(filename + ' does not list a .dsc file')
elif filename.endswith('.dsc'):
dsc = Dsc(f)
dscfile = filename
return changes, dsc, dscfile
else:
raise Exception(filename + ' is not a .dsc or .changes file')
except IOError:
raise Exception(filename + " couldn't be read")
raise WrongArgs(filename + ' is not a .dsc or .changes file')
except FileNotFoundError as e:
raise OscIOError(e, "File " + filename + " not found.")
except IOError as e:
raise OscIOError(e, "File " + filename + " couldn't be read.")
class DPut(object):
......@@ -94,8 +97,7 @@ class DPut(object):
return package
else:
print("Package folder couldn't be created")
raise Exception("Package folder couldn't be created")
raise IOError("Package folder couldn't be created")
def get_remote_file_list(self, package):
"""
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment