public static function assert(\DOMDocument $dom) {
        $queryNode = (new \DOMXPath($dom))->query("/BPQL/header/exception");
        if ($queryNode->length) {
            $nodeException = $queryNode->item(0);
            $source = $nodeException->getAttribute("source");
            $code = $nodeException->getAttribute("code");
            $id = $nodeException->getAttribute("id");
            $pushable = ($nodeException->getAttribute("pushable") ?: $nodeException->getAttribute("push")) === "true";
            $message = $nodeException->nodeValue;

            $e = new Exception(sprintf("[%s:%s/%s] %s", $code, $source, $id, $message, $pushable), $code);
            $e->setAttributes($code, $source, $id, $message, $pushable);
            throw $e;
        }
    }