public static function createUsingErrors(array $errors)
    {
        $message = "An error was encountered reading an XML document:\n";

        foreach ($errors as $error) {
            switch ($error->level) {
                case LIBXML_ERR_ERROR:
                    $message .= '[Error] ';
                    break;
                case LIBXML_ERR_FATAL:
                    $message .= '[Fatal] ';
                    break;
                case LIBXML_ERR_WARNING:
                    $message .= '[Warning] ';
                    break;
            }

            $message .= sprintf(
                "[line %d] [column %d] %s in \"%s\".\n",
                $error->line,
                $error->column,
                trim($error->message),
                $error->file
            );
        }

        return new self($message);
    }