Handle Curl exceptions

@param $url
@param $errno
@param $message
@param $logger
@throws \Adyen\ConnectionException
167739
protected function handleCurlError($url, $errno, $message, $logger)
	{
		switch ($errno) {
			case CURLE_OK:
				$msg = "Probably your Web Service username and/or password is incorrect";
				break;
			case CURLE_COULDNT_RESOLVE_HOST:
			case CURLE_OPERATION_TIMEOUTED:
				$msg = "Could not connect to Adyen ($url).  Please check your "
					. "internet connection and try again.";
				break;
			case CURLE_SSL_CACERT:
			case CURLE_SSL_PEER_CERTIFICATE:
				$msg = "Could not verify Adyen's SSL certificate.  Please make sure "
					. "that your network is not intercepting certificates.  "
					. "(Try going to $url in your browser.)  "
					. "If this problem persists,";
				break;
			default:
				$msg = "Unexpected error communicating with Adyen.";
		}
		$msg .= "\n(Network error [errno $errno]: $message)";
		$logger->error($msg);
		throw new \Adyen\ConnectionException($msg, $errno);
	}
1125684
private function handleCurlError($error, $errorNumber, $verbose): void
    {
        if (!$error) {
            return;
        }

        $errorMessage = "\ncURL transport error: $errorNumber - $error";

        $transportException = new TransportException($errorMessage);

        rewind($verbose);

        $verboseLog = stream_get_contents($verbose);

        if ($verboseLog !== false) {
            $verboseLog = htmlspecialchars($verboseLog);

            $transportException->setData($verboseLog);
        }

        throw $transportException;
    }
290471
public static function sendError($handle, $errorMessage) {
        $buffer = self::_parseError($errorMessage);
        return self::_writeToServer($handle, $buffer);
    }
590579
protected function _handle_error($curl)
	{
		// Get the error code and message
		$code  = curl_errno($curl);
		$error = curl_error($curl);

		$this->_close($curl);

		throw new Exception_Source(
			'Fetching :source_name data failed: :error (:code)',
			'remote',
			array(
				':error' => $error,
				':code' => $code
			)
		);
	}
735161
private void handleLogMessageException(final Exception exception, final String fqcn, final Message msg) {
        if (exception instanceof LoggingException) {
            throw (LoggingException) exception;
        }
        final String format = msg.getFormat();
        final StringBuilder sb = new StringBuilder(format.length() + 100);
        sb.append(fqcn);
        sb.append(" caught ");
        sb.append(exception.getClass().getName());
        sb.append(" logging ");
        sb.append(msg.getClass().getSimpleName());
        sb.append(": ");
        sb.append(format);
        StatusLogger.getLogger().warn(sb.toString(), exception);
    }
961336
public function setLogger($logger)
    {
        if (!method_exists($logger, 'info'))
        {
            throw new Exception('logger need have method "info($message)"');
        }
        if (!method_exists($logger, 'error'))
        {
            throw new Exception('logger need have method "error($message)"');
        }
        $this->logger = $logger;
    }
465950
protected function _processException(Zend_Http_Client_Exception $exception, $uri)
    {
        $this->_status = 0;
        $config = $this->_getHandlerConfig($this->_getHandlerKey());
        $logMethod = isset($config['logger']) ? $config['logger'] : 'debug';
        // the zend http client throws exceptions that are generic and make it impractical to
        // generate a message that is more representative of what went wrong.
        $logData = array_merge(['rom_request_url' => $uri], $this->_logAppContext);
        $logMessage = "Problem with request to {$uri}:\n{$exception->getMessage()}";
        $this->_logger->$logMethod($logMessage, $this->_context->getMetaData(__CLASS__, $logData, $exception));
        $callbackConfig = isset($config['callback']) ? $config['callback'] : array();
        return Mage::helper('radial_core')->invokeCallBack($callbackConfig);
    }
302429
public function handle($errorLevel, $message, $file, $line, $context) {

		if ($this->errorLevel === 0) {
			return FALSE;
		}

		if (
			$this->displayErrors &&
			error_reporting() & $errorLevel &&
			$this->errorLevel & $errorLevel
		) {
			throw new \ErrorException(sprintf(
				'%s: %s in %s line %d',
				isset($this->errorLevels[$errorLevel]) ? $this->errorLevels[$errorLevel] : $errorLevel,
				$message,
				$file,
				$line
			), 0, $errorLevel, $file, $line);
		}

		return FALSE;
	}
1236245
protected function err($message, $stopExec = false)
    {
        common_Logger::e($message);
        echo $this->out($message, array('color' => 'light_red'));
        
        if($stopExec == true){
            $this->handleError(new Exception($message, 1));
        }
    }
1271102
private function curlException($message, $code) {
        if (!array_key_exists($code, $this->getExceptionCodeMappings())) throw new CurlExceptions\CurlException("Error: {$message} and the Error no is: {$code} ", $code);

        $exceptionClass = $this->exceptionsNamespace . '\\' . $this->getExceptionCodeMappings()[$code];
        if (!class_exists($exceptionClass)) throw new \RuntimeException(
            $exceptionClass . ' does not exist. Check class var $exceptionCodeMappings in Circle\RestClientBundle\Traits\Exceptions.'
        );
        throw new $exceptionClass($message, $code);

    }
921057
public function handleError($errno, $errstr, $errfile, $errline, array $errcontext = [])
    {
        $msg = sprintf('%s: %s', self::getErrorDescription($errno), $errstr);

        if ($errno & $this->thrownErrors) {
            throw new ErrorException($msg, 0, $errno, $errfile, $errline);
        }

        if ($this->logError($errno, $msg, $errfile, $errline)) {
            return true;
        }

        return false;
    }
505048
public function onIOError(Connection $conn, \Exception $ex)
    {
        $this->onPublishResponse($conn, "IO_ERROR", $ex);

        try {
            $this->lookup->removeConnection($conn);
            $conn->tryClose();
        } catch (\Throwable $ignore) {
            sys_echo("nsq({$conn->getAddr()}) onIOError exception: {$ex->getMessage()}");
        } catch (\Exception $ignore) {
            sys_echo("nsq({$conn->getAddr()}) onIOError exception: {$ex->getMessage()}");
        }
    }
1013652
def exception(self, message, *args, **kwargs):
        
        self.logger.exception(message, *args, **kwargs)
572870
protected function _open($url)
    {
        set_error_handler(function ($code, $message) {
            $this->_connectionErrors[] = $message;
        });
        try {
            $this->_stream = fopen($url, 'rb', false, $this->_context);
        } finally {
            restore_error_handler();
        }

        if (!$this->_stream || !empty($this->_connectionErrors)) {
            throw new Exception(implode("\n", $this->_connectionErrors));
        }
    }
1284461
public function logException($level, $message, array $context = [], $exception = null)
    {
        $this->log($level, $message, array_merge($context, ['exception'=>$exception]));
    }
273219
protected function checkForCurlErrors()
    {
        if (curl_errno($this->getHandle())) {
            $exceptionText = "Connection Error: " . curl_error($this->getHandle());
            throw new ConnectionException($exceptionText);
        }
    }
541753
protected function err($msg, $url = null)
    {
        $this->saveDataInSession();
        return $this->msg($msg, self::MSG_BAD, $url);
    }