protected function raiseCurlError($ch, $function)
    {
        $env = $this->config->getEnvironment();
        $message = sprintf('%s (curl: %s): ', $function, $env['curlVersion']);
        if ($ch) {
            $code = curl_errno($ch);
            $message .= sprintf('%d - %s', $code, curl_error($ch));
        } else {
            $code = 703;
            $message .= 'no curl handle';
        }
        curl_close($ch);
        throw new RuntimeException($message, $code);
    }