error handling in alert and prompt