Review Request 299: openlmi-providers: Added global function to parse InstanceID.

Jan Safranek reviewboard at gallagherhome.com
Fri May 10 08:01:44 UTC 2013



> On May 2, 2013, 11:50 a.m., Michal Minar wrote:
> > src/python/openlmi/common/__init__.py, lines 25-42
> > <http://reviewboard-openlmi.rhcloud.com/r/299/diff/1/?file=1819#file1819line25>
> >
> >     I agree with Roman, I'm just not sure if the CIM error is the correct one to use here:
> >     raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND, 'Failed to parse id "%s"' % instance_id)
> >     Looking at your code, it seems that you don't parse the user's input but something generated by your code. In that case I would go for a new subclass of ValueError.

Exceptions are double-edge sword. I have in my code:

id = parse_instance_id(instance_id, classname)
if not id:
    raise pywbem.CIMError(.., "<concrete error message").

If I raise exception in parse_instance_id, I get generic error message in the exception and if I want specific one, I have to wrap everything into try:/except:, which then looks ugly. I leave the patch as it is.

(This is concept I started to use long time ago, when storage provider started; I do not claim it is the best one).


- Jan


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://reviewboard-openlmi.rhcloud.com/r/299/#review346
-----------------------------------------------------------


On May 2, 2013, 11:01 a.m., Jan Safranek wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://reviewboard-openlmi.rhcloud.com/r/299/
> -----------------------------------------------------------
> 
> (Updated May 2, 2013, 11:01 a.m.)
> 
> 
> Review request for OpenLMI Developers.
> 
> 
> Repository: openlmi-providers
> 
> 
> Description
> -------
> 
> Added global function to parse InstanceID.
> 
> 
> Diffs
> -----
> 
>   src/python/openlmi/common/JobManager.py e78967cea04cecf8b31ab9e4c5e4442c127411f4 
>   src/python/openlmi/common/__init__.py 2d19515e863dd592a628d8ab935a39b0cf1e831f 
> 
> Diff: http://reviewboard-openlmi.rhcloud.com/r/299/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Jan Safranek
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.fedorahosted.org/pipermail/openlmi-devel/attachments/20130510/f4279a2f/attachment.html>


More information about the openlmi-devel mailing list