question: private Map < String , String > checkForErrorsAndReturnResponse ( HttpsURLConnection connection ) { try { if ( connection . getResponseCode ( ) >= SC_MULTIPLE_CHOICES ) { String message ; if ( connection . getErrorStream ( ) != null ) { message = readResponse ( connection . getErrorStream ( ) ) ; } else { message = "" ; } if ( message . contains ( HTML_TAG ) ) { message = message . substring ( message . indexOf ( BODY_OPENING_TAG ) + 6 , message . indexOf ( BODY_CLOSING_TAG ) ) ; } throw new MCApiRuntimeException ( message , connection . getResponseCode ( ) ) ; } else { Map < String , String > responseMap = new HashMap < String , String > ( ) ; responseMap . put ( MESSAGE , readResponse ( connection . getInputStream ( ) ) ) ; responseMap . put ( HTTP_CODE , String . valueOf ( connection . getResponseCode ( ) ) ) ; return responseMap ; } } catch ( IOException e ) { throw new MCApiRuntimeException ( readResponse ( connection . getErrorStream ( ) ) ) ; } }
target:  Method to check the connection response for errors. Returns the response if the response code is less than 300. Throws MCOpenApiRuntimeException is connection errors.