Handle exceptions, print error messages.