Error handling and dynamic endpoint switch