Add API function to print out error messages