Better error handling in import_string