Minor code improvement

Don't trigger error if it's null.  Do the null-check before the try/catch,
not during the catch