handle exception if no tty