implemented error handling functions to print error messages