catch errors and display useful messages