azure-storage-common/src/Common/Middlewares/HistoryMiddleware.php
protected function onRejected(RequestInterface $request, array $options)
    {
        $reflection = $this;
        return function ($reason) use (
            $reflection,
            $request,
            $options
        ) {
            $reflection->addHistory([
                'request' => $request,
                'reason'  => $reason,
                'options' => $options
            ]);
            return new RejectedPromise($reason);
        };
    }
protected function onRejected(RequestInterface $request, array $options)
    {
        $reflection = $this;
        return function ($reason) use (
            $reflection,
            $request,
            $options
        ) {
            $reflection->addHistory([
                'request' => $request,
                'reason'  => $reason,
                'options' => $options
            ]);
            return new RejectedPromise($reason);
        };
    }
This function will be executed after the request is sent, if
the promise is rejected.

@param  RequestInterface $request the request sent.
@param  array            $options the options that the request sent with.

@return callable