Convert a URLFetch error code to a cURL error number, with message.

@param int $urlfetch_error The URLFetch error number.
@param string $urlfetch_message The URLFetch error string.
489467
private function setCurlErrorFromUrlFetchError($urlfetch_error,
                                                 $urlfetch_message) {
    if (array_key_exists($urlfetch_error, self::$urlfetch_curl_error_map)) {
      $this->setError(self::$urlfetch_curl_error_map[$urlfetch_error],
                      $urlfetch_message);
    } else {
      $this->setError(-1, $urlfetch_message);  // Maps to "Unknown Error".
    }
  }
1035570
public static function jsonErrorToException($json_error_code)
    {
        switch ($json_error_code) {
            case JSON_ERROR_DEPTH:
                return JsonEncodeDecodeException::depth();

            case JSON_ERROR_STATE_MISMATCH:
                return JsonEncodeDecodeException::stateMismatch();

            case JSON_ERROR_CTRL_CHAR:
                return JsonEncodeDecodeException::ctrlChar();

            case JSON_ERROR_SYNTAX:
                return JsonEncodeDecodeException::syntax();

            case JSON_ERROR_UTF8:
                return JsonEncodeDecodeException::utf8();

            case JSON_ERROR_RECURSION:
                return JsonEncodeDecodeException::recursion();

            case JSON_ERROR_INF_OR_NAN:
                return JsonEncodeDecodeException::infOrNan();

            case JSON_ERROR_UNSUPPORTED_TYPE:
                return JsonEncodeDecodeException::unsupportedType();

            case 9: // JSON_ERROR_INVALID_PROPERTY_NAME: // Available since PHP 7.0.0
                return JsonEncodeDecodeException::invalidPropertyName();

            case 10: // JSON_ERROR_UTF16: // Available since PHP 7.0.0
                return JsonEncodeDecodeException::utf16();
        }

        return JsonEncodeDecodeException::unknown();
    }
826896
public function httpError($code, $message = null)
    {
        if ($this->request->isMedia() || !$response = ErrorPage::response_for($code)) {
            parent::httpError($code, $message);
        } else {
            throw new HTTPResponse_Exception($response);
        }
    }
868319
public void notifyError( URL resource, String message )
    {
        m_out.println( resource.toExternalForm() + " : " + message );
    }
189894
public function raise_error($code, $message)
    {
        if ($code == 403) {
            header('HTTP/1.1 403 Forbidden');
            die("Invalid Request");
        }

        $this->show_message("Application Error ($code): $message", 'error');
        $this->remote_response();
        exit;
    }
641301
def get_error_code_msg(cls, full_error_message):
        
        for pattern in cls.ERROR_PATTERNS:
            match = pattern.match(full_error_message)
            if match:
                # assert match.group('type1') == match.group('type2')
                return int(match.group('code')), match.group('msg').strip()

        return 0, full_error_message
950011
function(message, index) {
			var error = new Error(message + ' at character ' + index);
			error.index = index;
			error.description = message;
			throw error;
		}
33537
private function checkForError(){
        $curlErrNo = curl_errno($this->CurlRequest);
        if ($curlErrNo !== CURLE_OK) {
            $this->error = TRUE;
            $this->CurlError = array(
                'error' => $curlErrNo,
                'error_message' => curl_error($this->CurlRequest)
            );
        }
    }
1064040
private void sendErrorMessage(StatusCodes code) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Sending an error page back [code: " + code + "]");
        }
        try {
            getHTTPContext().sendError(code.getHttpError());
        } catch (MessageSentException mse) {
            // no FFDC required
            close(getVirtualConnection(), new Exception("HTTP Message failure"));
        }
    }
718271
def error(self, status_code, request, message=None):
        
        status_code_text = HTTP_STATUS_CODES.get(status_code, 'http error')
        status_error_tag = status_code_text.lower().replace(' ', '_')
        custom_response_map = {
            404: self.make_error_response(
                status_error_tag,
                'The requested URL {} was not found on this service.'.format(
                    request.path
                )
            ),
            400: self.make_error_response(status_error_tag, message),
            405: self.make_error_response(
                status_error_tag,
                'The requested URL {} was not allowed HTTP method {}.'.format(
                    request.path, request.method
                )
            ),
        }
        return self._raw_response(
            status_code,
            custom_response_map.get(
                status_code,
                self.make_error_response(
                    status_error_tag, message or status_code_text
                )
            )
        )
442143
protected function _error($message, $code)
    {
        header("HTTP/1.0 {$code} {$message}");
        echo $message;

        TableRegistry::get('Field.FieldInstances')->connection()->disconnect();
        exit(0);
    }
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);
	}
109962
public function setErrorCallbackFunction($errorCallbackFunction, $errorMsgFormat = "html")
    {
        //Variable functions for won't work with language constructs such as echo and print, so these are replaced with print_r.
        if (in_array(strtolower($errorCallbackFunction), array("echo", "print")))
            $errorCallbackFunction = "print_r";

        if (function_exists($errorCallbackFunction)) {
            $this->_errorCallbackFunction = $errorCallbackFunction;
            if (!in_array(strtolower($errorMsgFormat), array("html", "text")))
                $errorMsgFormat = "html";
            $this->_errorMsgFormat = $errorMsgFormat;
        }
    }
1300561
def api_errors_to_messages(request, error, fallback_text):
    
    try:
        response_body = json.loads(error.content.decode('utf-8'))
        for field, errors in response_body.items():
            if isinstance(errors, list):
                for error in errors:
                    messages.error(request, error)
            else:
                messages.error(request, errors)
    except (AttributeError, ValueError, KeyError):
        messages.error(request, fallback_text)
639872
public function reportError(string $error_message) : void
    {
        $error_message = sprintf($error_message, $this->field_name);
        if (null != $this->validation_set) {
            $this->validation_set->addValidationError(new ValidationError($this->field_name, $error_message));
        }
    }
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);

    }
841711
def send_http_error(self, http_code, cim_error=None,
                        cim_error_details=None, headers=None):
        
        self.send_response(http_code, http_client.responses.get(http_code, ''))
        self.send_header("CIMExport", "MethodResponse")
        if cim_error is not None:
            self.send_header("CIMError", cim_error)
        if cim_error_details is not None:
            self.send_header("CIMErrorDetails", cim_error_details)
        if headers is not None:
            for header, value in headers:
                self.send_header(header, value)
        self.end_headers()
        self.log('%s: HTTP status %s; CIMError: %s, CIMErrorDetails: %s',
                 (self._get_log_prefix(), http_code, cim_error,
                  cim_error_details),
                 logging.WARNING)