protected void handleResponseCode(HttpURLConnection conn) throws WebServiceSystemException, IOException {
// First check response code
int responseCode = conn.getResponseCode();
String errorReason = conn.getHeaderField(ErrorReason.HTTP_RESPONSE_HEADER_NAME);
if (responseCode >= 400 || GreazeStrings.isNotEmpty(errorReason)) {
ErrorReason reason = GreazeStrings.isEmpty(errorReason)
? ErrorReason.fromHttpResponseCode(responseCode)
: ErrorReason.valueOf(errorReason);
String msg = Streams.readAsString(conn.getInputStream());
throw new WebServiceSystemException(reason, "Server input: " + msg);
}