catch exceptions and print error