Altered error handling to treat REST URLs differently.