Menu

#6 unclear exception text when accessing non existing column

open
nobody
None
5
2013-01-15
2009-05-27
No

ValueError: list.index(x): x not in list

is the standard python exception plus text when looking for an item in a list that does not contain the item. this exception is raised when you attempt accessing a non existing column.

that 'x' does not really help finding what column you were trying to access, what about this:

def indexOfFieldName(self, name):
"""Index of field named ``name``."""
# FIXME: move this to header class
try:
return self.header.fields.index(name)
except ValueError:
raise ValueError("can't find index of field '%s'" % name)

Discussion


Log in to post a comment.

MongoDB Logo MongoDB