public function createUsingLastXmlError()
    {
        $errors = array();
        $count = 0;

        /** @var \libXMLError $error */
        foreach (libxml_get_errors() as $error) {
            $errors[] = sprintf(
                '#%d.) "%s" in %s line %d column %d.',
                ++$count,
                trim($error->message),
                $error->file,
                $error->line,
                $error->column
            );
        }

        $this->finish();

        if (empty($errors)) {
            $errors[] = '(unknown error)';
        }

        return new self(join("\n", $errors));
    }