Added try/catch handler and echoed message in html