Added an error message to the list function.

It will now break out of the loop and return an error if something unexpected
is given to it.