Eric Schwartz is president of Refugees International.

In recent years, the West has become obsessed with the problem of refugees — and generally not in a good way. The United States and other wealthy countries have been unkind at best, and hostile at worst, to refugees. Politicians and voters fixate on security threats, economic costs, the challenges of integration — even though studies show that these risks are invariably overblown.

Largely unnoticed in these agonized discussions is the fact that it is poor countries, not rich ones, who bear the brunt of responsibility of providing safe haven for refugees. Yet despite their lack of resources, some of these nations are doing an extraordinary job of coping — to an extent that puts the more privileged parts of the world to shame.

Consider the surprising example of Uganda. At a time when the U.S. government in particular seems determined to treat refugees as a nuisance and a risk, Uganda has emerged as an example of compassion and generosity toward refugees. Wealthier nations could learn much from its example.

In November 2010, I visited southern Sudan as its population prepared for a historic vote on independence that many hoped would represent a new beginning and an end to violence that had plagued its people for so long. A hard-won peace agreement ended the country’s long-running civil war, which had pitted the authorities in Khartoum against the southern Sudanese people of the sub-Saharan region of the country. In January 2011, the people of southern Sudan voted overwhelmingly to become the independent state of South Sudan.

To be sure, there was pervasive uncertainty about the future during my visit. South Sudan embarked on independence as one of the poorest countries in world, and there were deep concerns that divisions in the south that had been subsumed in the common effort against northern domination would escalate after independence.

This fear was tragically realized when terrible conflict broke out between forces loyal to South Sudanese President Salva Kiir and his former deputy Riek Machar in 2013.

As that conflict has unfolded over the past six years, the violence in South Sudan has been horrific, with grave humanitarian implications for the South Sudanese people, who have left and are continuing to leave the country in droves. South Sudan is now the fastest-growing refugee emergency in the world, with nearly 1.8 million people seeking asylum in neighboring countries — in dire need of food, shelter, water and other forms of humanitarian assistance. This places tremendous strain on host countries and organizations trying to assist them.

Uganda, with a population of about 40 million, now finds itself hosting nearly 1 million refugees from South Sudan. (Just imagine: The equivalent proportional number for the United States would be around 8 million.) And yet Kampala has opted to maintain open borders, despite the enormous flow of men, women and children fleeing the crisis in its neighbor. Even more remarkably, the country’s generous policies allow refugees access to land, health care, education and employment, all critical humanitarian measures that ease the burden of refuge for those fleeing for their lives. It is worth noting that Uganda’s policy allows humanitarian agencies to focus on what matters — serving refugees’ needs.

My colleague Francisca Vigaud-Walsh traveled to the South Sudanese-Ugandan border in December 2016, where she witnessed the ongoing exodus of those fleeing unspeakable acts of violence — and, perhaps most notably, sexual violence. Francisca collected dozens of testimonies from women who had been subjected to rape and other forms of gender-based violence. Indeed, that same month, U.N. human rights investigators said that rape was being used a tool for ethnic cleansing, and that sexual violence in the country had reached epic proportions. The women Francisca interviewed expressed tremendous gratitude for the security that Uganda’s open borders, positive support and generous refugee policies provided.

It is true that Uganda’s record is not spotless. It has been accused of playing a destructive role in the internal affairs of South Sudan, and the large movement of refugees into the country has caused plenty of internal tensions. And other practices in Uganda, such as harsh discrimination against the LGBT community, are very disturbing. But that doesn’t alter the simple fact that the Ugandan government has taken measures that have benefited hundreds of thousands of South Sudanese. And by declaring recently that refugees are “an important part of the Ugandan national development plan,” and are treated “as an opportunity rather than a threat,” Uganda’s refugee commissioner offered a valuable lesson to governments of the world that have taken a far more negative approach.

No matter the progress that governments may make in addressing root causes of conflict, the challenges — and opportunities — presented by refugee flight will continue into the foreseeable future. For those governments and citizens feeling the effects of compassion fatigue, the actions of the government of Uganda demonstrate that all is not lost, and that compassionate policies can offer a better and more hopeful way ahead.