Catching errors and showing alert