On 12/18/12 15:18, Erik Trauschke wrote:


On 12/18/12 11:45 AM, Shawn Walker wrote:
I think InvalidOptionException needs to be restructured so that it more
naturally handles any number of invalid options. In particular, I'd also
expect the __verify_args in pkg.client.api to find as many invalid
options as it can before raising the related exception.

Otherwise, this is satisfactory for the moment, although consumers of
this will have to manually scan the options that were found to be
invalid in the exception and map those to actual options to make it
useful for users. With that in mind, maybe there should be a property to
map the options to the consumer's representation. For example:

As we discussed in person, doing the option mapping in the exception is
tricky because not all required information might be available. It
should work better if we provide the options in the exception itself and
the caller can extract and translate them if necessary.

I implemented all the other suggestions.

webrev:
https://cr.opensolaris.org/action/browse/pkg/erisch/15981296_2/webrev/

src/modules/client/api.py:
  line 970: please add a brief docstring

line 1020: you can provide a useful error message for the assertion like this:

   isinstance(args[a], a_type)), "%s is type %s; "
   "expected %s" % (a, type(a), a_type)

  line 1058: s/len(errors) > 0:/errors:/

  line 1068: s/repos is None/not repos/

  line 1081: s/len(illegals) > 0:/illegals:/

  line 1084: extra newline


src/modules/client/api_errors.py:
  lines 1918-1919: delete

  lines 1920-1921: change to:
    if isinstance(uris, basestring):
        uris = [uris]
    assert isinstance(uris, (list, tuple, set))

  line 1927: delete

  line 1930-1935: delete

  lines 1936-1940: de-indent and rewrap

  line 1937: s/str/basestring/

  line 1950: delete

  line 1957: delete and de-indent 1958-1960


...
Once that above is fixed, can you provide sample output for a multiple invalid URI case?

Thanks,
-Shawn
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss

Reply via email to