private S waitForCompletionAndThrowIfUploadFailed ( ) throws IOException { try { return uploadOperation . get ( ) ; } catch ( InterruptedException e ) { // If we were interrupted, we need to cancel the upload operation. uploadOperation . cancel ( true ) ; IOException exception = new ClosedByInterruptException ( ) ; exception . addSuppressed ( e ) ; throw exception ; } catch ( ExecutionException e ) { if ( e . getCause ( ) instanceof Error ) { throw ( Error ) e . getCause ( ) ; } throw new IOException ( "Upload failed" , e . getCause ( ) ) ; } }
Throws if upload operation failed . Propagates any errors .