catch errors and alert