[Bf-python] API inconsistencies: Exception types
Joseph Gilbert
models at paposo.com
Fri Aug 19 05:04:54 CEST 2005
Yea this is a bit of a bugger. I've used them inconsistantly myself :/
They however are defined as follows:
AttributeError - Thrown when an attribute reference or assignment has failed
TypeError - Thrown when your trying to perform an operation on an
inappropriate type
ValueError - Thrown when your trying to perform an operation on an
appropriate type with an inappropriate value
Ken Hughes wrote:
> Another rant/question for API inconsistencies:
>
> Is there some general consensus (and if so, is it already in of the
> Blender coding docs, and if not can someone put it there?) as to what
> type of exceptions to throw when? I've seen PyExc_TypeError,
> PyExc_ValueError and PyExc_AttributeError used somewhat
> interchangeably (and I'm guilty too). Would the following be Good
> Rules(tm)?
>
> (1) PyExc_TypeError: the user passes a parameter which is of the wrong
> type (string instead of int, list instead of tuple, whatever), such that
> it would cause PyArg_ParseTuple() to fail
> (2) PyExc_AttributeError: the user refers to an attribute which
> doesn't exist ("print Blender.Object.Get('Cube').bogus")
> (3) PyExc_ValueError: the user passes a parameter of the correct type,
> but with an invalid value ("Blender.Object.New.('Bogus')")
>
> I know this isn't a big deal, but I've had a lot of caffiene today.
>
> Ken
> _______________________________________________
> Bf-python mailing list
> Bf-python at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-python
>
>
>
More information about the Bf-python
mailing list