Catching error and outputting message