You could move the function declaration outside the try. It would be clearer what you're testing.