add catch block to make it works as expected

Without `catch` block, `try` will not work as expected, still throwing errors.