https://bugzilla.novell.com/show_bug.cgi?id=280034#c5 --- Comment #5 from Marcus Hüwe <suse-tux@gmx.de> 2007-10-27 12:16:07 MST --- Today I wrote a more extended version of this exception handling. With this new version all urllib2.HTTPError exceptions will be catched in the http_request() method (thanks to darix for hinting me to this method and his remarks:) ) unless a parameter is added to the http_GET, http_PUT... calls which forces the http_request() method to re-raise the exception so that it can be handled in calling method (this is needed in some cases). If you now run "osc dosth <non-existing>" it will print a generic error message for 404-errors (if you need a more precise error message you can easily overwrite the standard message - so it's still flexible IMHO). I attached a small diff (with the current implementation osc will probably often raise an "AttributeError" exception which can be ignored atm). usage: # all urllib2.HTTPError exceptions will be catched: f = http_GET(u) # no exceptions will be catched (so this line should by nested in a try-except block): f = http_GET(u, hasHandler=True) # if a 404 exception is raised it'll print 'user does not exist' instead of 'no such file or package or project' (standard message) hdl = HTTPError_Handler('404', 'user does not exist', None) f = http_GET(u, hasHandler=False, customHandlers={ '404' : hdl }) -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.