make SCM URL validity check more verbose

When a builder parses an SCM URL, the daemon module's _parse_url() does
a sanity check that it has properly understood all the necessary
elements of the URL string before returning them. When this check fails,
a "Invalid URL" message is raised, but this error message does not
provide information about what portion of the URL was missing.

Break this sanity check into multiple statements, so that we present a
more detailed error message to the user.
This commit is contained in:
Ken Dreyer 2011-11-28 19:40:33 -07:00 committed by Mike McLean
parent 82ea18aa54
commit 4d42e1062e

View file

@ -237,8 +237,16 @@ class SCM(object):
query = query[:-1]
# check for validity: params should be empty, query may be empty, everything else should be populated
if params or not (scheme and netloc and path and fragment):
raise koji.GenericError, 'Unable to parse SCM URL: %s' % self.url
if params :
raise koji.GenericError, 'Unable to parse SCM URL: %s . Param element %s should be empty.' % (self.url,param)
if not scheme :
raise koji.GenericError, 'Unable to parse SCM URL: %s . Could not find the scheme element.' % self.url
if not netloc :
raise koji.GenericError, 'Unable to parse SCM URL: %s . Could not find the netloc element.' % self.url
if not path :
raise koji.GenericError, 'Unable to parse SCM URL: %s . Could not find the path element.' % self.url
if not fragment :
raise koji.GenericError, 'Unable to parse SCM URL: %s . Could not find the fragment element.' % self.url
# return parsed values
return (scheme, user, netloc, path, query, fragment)