Improved exception handling
Only throw invalid response exception on empty response when there are errors, and improve exception handling.
Only throw invalid response exception on empty response when there are errors, and improve exception handling.