Remove a useless if statement and add a try block to avoid an error.

It is not clear for me why the try block is necessry here.  This should
probably be fixed more properly.