Fix error handling when http resonse is not 200.