protected IOException readError ( final HttpURLConnection connection ) throws IOException { int status = connection . getResponseCode ( ) ; InputStream input = connection . getErrorStream ( ) ; try { String message = input == null ? "No error description" : readString ( connection , input ) ; if ( message . length ( ) > MAX_RPC_EXCEPTION_MESSAGE_LEN ) { message = message . substring ( 0 , MAX_RPC_EXCEPTION_MESSAGE_LEN ) + "..." ; } message = message . replace ( "\n" , " " ) ; message = message . replace ( "\r" , " " ) ; throw new RpcException ( status , message ) ; } finally { closeLogExc ( input ) ; } }
Reads an unexpected exception throws RpcException .