Handle error retrieval in print_error() when an error message is not already set.