Define la cabeza de un pedido.
@param array El contenido de la cabeza.
@throws \ErrorException
427704
public function addHeaders(array $headers)
    {
        $this->head = array_merge($this->head, $headers);
        curl_setopt($this->curlHandler, CURLOPT_HTTPHEADER, $this->head);
        return $this;
    }
952776
public function showError($msg = null)
    {
        $errorMessage = null;
        $code = null;
        if ((null === $code) && (null === $msg)) {
            $errorCode = $this->connection->errorCode();
            $errorInfo = $this->connection->errorInfo();
        } else {
            $errorCode = $code;
            $errorInfo = $msg;
        }
    
        if (is_array($errorInfo)) {
            $errorMessage = null;
            if (isset($errorInfo[1])) {
                $errorMessage .= $errorInfo[1];
            }
            if (isset($errorInfo[2])) {
                $errorMessage .= ' : ' . $errorInfo[2];
            }
        } else {
            $errorMessage = $errorInfo;
        }
        throw new Exception('Error: ' . $errorCode . ' => ' . $errorMessage  . '.');
    }
743164
private function buildDefinition(array $array)
    {
        $definition = null;
        if (isset($array['parent'])) {
            $definition = new DefinitionDecorator($array['parent']);
        } else {
            $definition = new Definition();
        }

        if (isset($array['synthetic'])) {
            $definition->setSynthetic($array['synthetic']);
        }

        $this->setDefinitionClass($definition, $array);
        $this->setDefinitionArguments($definition, $array);
        $this->setDefinitionFactory($definition, $array);
        $this->setDefinitionTags($definition, $array);
        $this->setDefinitionMethodCalls($definition, $array);
        $this->setDefinitionProperties($definition, $array);
        $this->setDefinitionConfigurator($definition, $array);

        return $definition;
    }
333898
public function setInstructions($instructions)
    {
        if (!is_null($this->_instructions)) {
            throw new Exception('Instructions for browser responses can only be set once.');
        }
        $this->_instructions = array_merge($this->_baseInstructions, $instructions);
        if (isset($this->_instructions['id'])) {
            $this->_id = $this->_instructions['id'];
        }
        if (isset($this->_instructions['offset'])) {
            $this->_offset = $this->_instructions['offset'];
        }
        if (isset($this->_instructions['filterQuery'])) {
            $this->filterQuery = $this->_instructions['filterQuery'];
        }

        unset($this->_instructions['id'], $this->_instructions['offset'], $this->_instructions['filterQuery']);
    }
719742
public function error( $code ) {
		header( $_SERVER["SERVER_PROTOCOL"] . Route::$HttpResponse[ $code ] );

		if ( $this->config->get( "error.$code" ) != '' ) {
			echo $this->render( $this->config->get( 'path.template' ) . '/' . $this->config->get( "error.$code" ) . '.php' );
		} else {
			die( Route::$HttpResponse[ $code ] );
		}

	}
738248
public function withErrors(array $errors = []): CollectionElement
    {
        $this->allErrors = $errors;

        array_walk(
            $this->elements,
            function (ElementInterface $element) use ($errors) {
                $name = $element->name();
                if (isset($errors[$name]) && $element instanceof ErrorAwareInterface) {
                    $element->withErrors($errors);
                    unset($errors[$name]);
                }
            }
        );

        // assign errors without matches to the collection itself.
        $this->errors = $errors;

        return $this;
    }
519799
public static function setError($id, $errors, $element = "")
    {
        if (!is_array($errors)) {
            $errors = array($errors);
        }

        if (empty($_SESSION["form"][$id]["errors"][$element])) {
            $_SESSION["form"][$id]["errors"][$element] = array();
        }

        foreach ($errors as $error) {
            $_SESSION["form"][$id]["errors"][$element][] = $error;
        }
    }
1024413
public function addError($key, $error) {
        if (is_array($key)) {
            $key = implode('_', $key);
        }

        if (array_key_exists($key, $this->errors)) {
            $this->errors[$key][] = $error;
        }
        else {
            $this->errors[$key] = array($error);
        }
    }
514409
public function setQueryVariables($array)
    {
        if (! is_array($array)) {

            throw new InvalidArgumentException('Must pass an array to setQueryVariables()');
        }

        $parts = array();

        foreach ($array as $name => $value) {

            $name = urlencode($name);

            if (! is_null($value)) {

                $parts[] = $name . '=' . urlencode($value);

            } else {

                $parts[] = $name;
            }
        }

        $this->setQuery(implode('&', $parts));
    }
382660
function setError( $errorNumber = 0, $errorDescription = "" )
    {
        $this->ERROR['number'] = $errorNumber;
        $this->ERROR['description'] = $errorDescription;

        switch( $errorNumber )
        {
            case self::ERROR_NOERROR :
                $this->ERROR['value'] = "";
                break;
            case self::ERROR_UNSUPPORTEDTYPE :
                $this->ERROR['value'] = ezpI18n::tr( 'extension/ezodf/import/error', "File extension or type is not allowed." );
                break;
            case self::ERROR_PARSEXML :
                $this->ERROR['value'] = ezpI18n::tr( 'extension/ezodf/import/error', "Could not parse XML." );
                break;
            case self::ERROR_OPENSOCKET :
                $this->ERROR['value'] = ezpI18n::tr( 'extension/ezodf/import/error', "Can not open socket. Please check if extension/ezodf/daemon.php is running." );
                break;
            case self::ERROR_CONVERT :
                $this->ERROR['value'] = ezpI18n::tr( 'extension/ezodf/import/error', "Can not convert the given document." );
                break;
            case self::ERROR_DAEMONCALL :
                $this->ERROR['value'] = ezpI18n::tr( 'extension/ezodf/import/error', "Unable to call daemon. Fork can not create child process." );
                break;
            case self::ERROR_DAEMON :
                $this->ERROR['value'] = ezpI18n::tr( 'extension/ezodf/import/error', "Daemon reported error." );
                break;
            case self::ERROR_UNKNOWNNODE:
                $this->ERROR['value'] = ezpI18n::tr( 'extension/ezodf/import/error', "Unknown node." );
                break;
            case self::ERROR_ACCESSDENIED:
                $this->ERROR['value'] = ezpI18n::tr( 'extension/ezodf/import/error', "Access denied." );
                break;
            case self::ERROR_IMPORTING:
                $this->ERROR['value'] = ezpI18n::tr( 'extension/ezodf/import/error', "Error during import." );
                break;
            case self::ERROR_UNKNOWNCLASS:
                $this->ERROR['value'] = ezpI18n::tr( 'extension/ezodf/import/error', "Unknown content class specified in odf.ini:" );
                break;
            default :
                $this->ERROR['value'] = ezpI18n::tr( 'extension/ezodf/import/error', "Unknown error." );
                break;
        }
    }
8655
public function execute($actionContext) {
        // make json and exit
        if (($result = json_encode($this->data, $this->options, $this->depth)) === false) {
            throw new \ErrorException('JSON encode error #' . json_last_error() . ': ' . json_last_error_msg());
        }

        $response = $actionContext->getHttpContext()->getResponse();
        $response->addHeader('Content-Type', 'application/json');
        $response->write($result);
        $response->end();
    }
209707
private function throwExceptionIfErrorOccurred()
    {
        $errorResultCodes = [
            \Memcached::RES_FAILURE,
            \Memcached::RES_SERVER_TEMPORARILY_DISABLED,
            \Memcached::RES_SERVER_MEMORY_ALLOCATION_FAILURE,
        ];

        if (in_array($this->memcached->getResultCode(), $errorResultCodes, true)) {
            throw new StorageException($this->memcached->getResultMessage());
        }
    }
1171034
public function setErrors($errors = array())
    {
        foreach ($errors as $error) {
            if (!$error instanceof ConstraintViolation) {
                throw new \InvalidArgumentException(sprintf('The supplied error is of class "%s", while a "Symfony\Component\Validator\ConstraintViolation" was expected.', get_class($error)));
            }
        }

        $this->errors = $errors;
    }
771258
public function error($message, array $context = [])
    {
        if ($message instanceof \Throwable) {
            $m = "[{$message->getCode()}] " . $message->getMessage();
            $m .= "\n";
            $m .= $message->getTraceAsString();
            $this->error($m, $context); // calling back this method with string argument
            return;
        }

        $this->log(LogLevel::ERROR, $message, $context);
    }
123987
public function addErrors(array $errors)
    {
        foreach ($errors as $error) {
            if (!$error instanceof ValidationError)
                throw new Exception('Error was not instance of ValidationError: '.$error);
            if (!in_array($error, $this->errors))
                $this->errors[] = $error;
        }

        return $this;
    }
47233
public function appendErrorList (array $error_list) {
		foreach ($error_list as $name => $error) {
			$this->appendError($name, $error);
		}
	}
782976
public function init(array $data = [])
    {
        foreach ($data as $key => $value) {
            $key = $this->getPreparedKey($key);
            $method = 'set' . str_replace(' ', '', $key);

            if (method_exists($this, $method)) {
                $this->{$method}($value);
            }
        }
    }