This method allows the exception to include additional information into the WebDAV error response.

@param DAV\Server  $server
@param \DOMElement $errorNode
500837
public function serialize(DAV\Server $server, \DOMElement $errorNode)
    {
        $error = $errorNode->ownerDocument->createElementNS('DAV:', 'd:number-of-matches-within-limits');
        $errorNode->appendChild($error);
    }
595437
private function handleSentinelErrorResponse(NodeConnectionInterface $sentinel, ErrorResponseInterface $error)
    {
        if ($error->getErrorType() === 'IDONTKNOW') {
            throw new ConnectionException($sentinel, $error->getMessage());
        } else {
            throw new ServerException($error->getMessage());
        }
    }
518656
public function addError(Exception $error)
    {
        $errorNode = $this->addElement("error", $error->getMessage());

        if (!$error instanceof NoRecordsMatchException) {
            $this->status = '400';
        }

        if ($error->getErrorName()) {
            $errorNode->setAttribute("code", $error->getErrorName());
        } else {
            $errorNode->setAttribute("code", "badArgument");
        }
    }
361247
public function enterNode(Node $node)
    {
        if ($node instanceof Assign && $node->var instanceof Variable && $node->var->name === 'this') {
            throw new FatalErrorException('Cannot re-assign $this', 0, E_ERROR, null, $node->getLine());
        }
    }
375594
public function theJsonNodeShouldNotExist($jsonNode)
    {
        $e = null;

        try {
            $realValue = $this->evaluateJsonNodeValue($jsonNode);
        } catch (\Exception $e) {
            // If the node does not exist an exception should be throwed
        }

        if ($e === null) {
            throw new WrongJsonExpectation(
                sprintf("The node '%s' exists and contains '%s'.", $jsonNode, json_encode($realValue)),
                $this->readJson(),
                $e
            );
        }
    }
151730
public static function withErrorCode($errorCode, $message, $innerException= null)
	{
		$ex = new XPath2Exception( $message, $innerException );
		$ex->ErrorCode = $errorCode;
		return $ex;
	}
1112845
private function extractAttributes(\DOMElement $node, array $data, $nodeName)
    {
        foreach ($data['@attributes'] as $key => $value) {

            if (! $this->isValidTagName($key)) {

                throw new \Exception(__CLASS__.' Illegal character in attribute name. attribute: '.$key.' in node: '.$nodeName);

            }

            $node->setAttribute($key, $this->boolToString($value));
        }
    }
631136
public function theJsonNodeShouldNotContain($jsonNode, $unexpectedValue)
    {
        $this->assert(function () use ($jsonNode, $unexpectedValue) {
            $realValue = $this->evaluateJsonNodeValue($jsonNode);
            $this->asserter->string((string) $realValue)->notContains($unexpectedValue);
        });
    }
600680
protected function triggerError ($errorMessage)
	{
		$this->hasError 	= true;
		$this->errorMessage	= $errorMessage;
		
		throw new Exception ($errorMessage);
	}
1139105
public function serialize(DAV\Server $server, \DOMElement $errorNode)
    {
        if ($this->header) {
            $prop = $errorNode->ownerDocument->createElement('s:header');
            $prop->nodeValue = $this->header;
            $errorNode->appendChild($prop);
        }
    }
1317583
public function RenderError ($exceptionMessage = '') {
		if ($this->application->IsErrorDispatched()) return;
		throw new \ErrorException(
			$exceptionMessage ? $exceptionMessage :
			"Server error: `" . htmlspecialchars($this->request->GetFullUrl()) . "`.",
			500
		);
	}
1297902
private function handleException($e)
    {
        // TODO: test coverage
        if ($e instanceof ClientException) {
            // will catch all 4xx errors
            if ($e->getResponse()->getStatusCode() == 403) {
                throw new AuthenticationException(
                    $this->apiKey,
                    $this->apiSecret,
                    null,
                    $e
                );
            } else {
                throw new DomainException(
                    'The OpenTok API request failed: '. json_decode($e->getResponse()->getBody(true))->message,
                    null,
                    $e
                );
            }
        } else if ($e instanceof ServerException) {
            // will catch all 5xx errors
            throw new UnexpectedValueException(
                'The OpenTok API server responded with an error: ' . json_decode($e->getResponse()->getBody(true))->message,
                null,
                $e
            );
        } else {
            // TODO: check if this works because Exception is an interface not a class
            throw new \Exception('An unexpected error occurred');
        }
    }
268259
public function handler($errno, $errstr, $errfile, $errline)
    {
        throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
    }
431779
public function handlerVerbose(\Exception $exception)
    {
        if (!headers_sent()) {
            header('HTTP/1.1 500 Internal Server Error', true, 500);
            header('Content-type: text/html; charset=UTF-8');
        }

        echo sprintf(
            '<!DOCTYPE html>
        <html>
        <head>
            <title>Bad Moss: %1$s - %2$s - %3$s:%4$u</title>
            <style>
                body, code { font: medium/1.5em monospace; }

                div:nth-child(4) { position: fixed; right: 0.5em; top: 0.5em; width: 100%; padding: 0.25em 1em; }
                div:nth-child(4) a { text-decoration: none; padding: 0.25em 0.75em; color: #ffe; background: #8c3; border-radius: 1em; }

                table { width: auto; border-collapse: collapse; overflow: hidden; }

                td { vertical-align: top; }
                td:nth-child(1) { position: relative; width: 3em; padding: 0 0.5em 0 0; text-align: right; color: #999; border-right: 1px solid #999; z-index: 1; }
                td:nth-child(2) { position: relative; padding: 0 0 0 0.5em; z-index: 2; }

                td, td span { white-space: nowrap; }
                td span#mark { position: relative; font-weight: bold; color: #f00; }
                td span#mark:after { content: \'.\'; position: absolute; top: -0.2em; left: -2em; width: 10000em; background: #f00; opacity: 0.25; }
            </style>
        </head>
        <body>
            <h1>Bad Moss: %1$s - &quot;%2$s&quot;</h1>

                <div>
                    <h2 id="trace">Trace</h2>
                    %6$s
                </div>
                <div>
                    <h2 id="listing">File: %3$s:%4$u</h2>
                    %5$s
                </div>
                <div>
                    <a href="#trace">Trace</a>
                    <a href="#listing">Listing</a>
                    <a href="#mark">Error line</a>
                </div>
        </body>
        </html>',
            get_class($exception),
            $exception->getMessage(),
            $exception->getFile(),
            $exception->getLine(),
            $this->lineNumbers('<br />', highlight_file($exception->getFile(), true), $exception->getLine()),
            $this->prettyCode($exception->getTrace())
        );
    }
402333
private void checkForError(JsonNode resp) throws WePayException
	{
		JsonNode errorNode = resp.get("error");
		if (errorNode != null)
			throw new WePayException(errorNode.asText(), resp.path("error_description").asText(), resp.path("error_code").asInt());
	}
479836
protected function addSequentialNode(DOMElement $element, $value): void
    {
        if (empty($element->nodeValue)) {
            $element->nodeValue = \htmlspecialchars($value);
            return;
        }

        $child = $this->element($element->nodeName);
        $child->nodeValue = \htmlspecialchars($value);
        $element->parentNode->appendChild($child);
    }
681829
public function logError(ContactEventLog $eventLog, $errorMessage)
    {
        // @todo - add translator for messages.
        $eventLog->addProperty('error', $errorMessage)
            ->setAction('failed');
        $this->ContactEventLogRepo->saveEntity($eventLog);
        // $this->logDebug('Line '. 1 .' error: '.'err', []);
    }