Handle API errors