Question: What are the possible exceptions that can be thrown when `XDocument.Load(XmlReader)` is called? It is hard to follow best practices (i.e. avoiding generic try catch blocks) when the documentation fails to provide crucial information.

Thanks in advance for your assistance.

Answer: 
MSDN says: The loading functionality of LINQ to XML is built upon XmlReader.Therefore, you might catch any exceptions that are thrown by the XmlReader. Create overload methods and the XmlReader methods that read and parse the document.

<http://msdn.microsoft.com/en-us/library/756wd7zs.aspx>
ArgumentNullException and SecurityException

EDIT: MSDN not always says true. So I've analyzed Load method code with reflector and got results like this:

```
public static XDocument Load(XmlReader reader)
{
    return Load(reader, LoadOptions.None);
}

```

Method Load is calling method:

```
public static XDocument Load(XmlReader reader, LoadOptions options)
{
    if (reader == null)
    {
        throw new ArgumentNullException("reader"); //ArgumentNullException
    }
    if (reader.ReadState == ReadState.Initial)
    {
        reader.Read();// Could throw XmlException according to MSDN
    }
    XDocument document = new XDocument();
    if ((options & LoadOptions.SetBaseUri) != LoadOptions.None)
    {
        string baseURI = reader.BaseURI;
        if ((baseURI != null) && (baseURI.Length != 0))
        {
            document.SetBaseUri(baseURI);
        }
    }
    if ((options & LoadOptions.SetLineInfo) != LoadOptions.None)
    {
        IXmlLineInfo info = reader as IXmlLineInfo;
        if ((info != null) && info.HasLineInfo())
        {
            document.SetLineInfo(info.LineNumber, info.LinePosition);
        }
    }
    if (reader.NodeType == XmlNodeType.XmlDeclaration)
    {
        document.Declaration = new XDeclaration(reader);
    }
    document.ReadContentFrom(reader, options); // InvalidOperationException
    if (!reader.EOF)
    {
        throw new InvalidOperationException(Res.GetString("InvalidOperation_ExpectedEndOfFile")); // InvalidOperationException
    }
    if (document.Root == null)
    {
        throw new InvalidOperationException(Res.GetString("InvalidOperation_MissingRoot")); // InvalidOperationException
    }
    return document;
}

```

Lines with exceptions possibility are commented

We could get the next exceptions:ArgumentNullException, XmlException and InvalidOperationException.
MSDN says that you could get SecurityException, but perhaps you can get this type of exception while creating XmlReader.
I was following a tutorial about [web scraping in .NET 6 using XDocument](https://www.c-sharpcorner.com/article/easily-do-web-scraping-in-net-core-6-0/). However, when I called `XDocument.Load("...")` to load an .html page, I got the following exception:

```
System.Xml.XmlException: ''src' is an unexpected token. The expected token is '='. Line 47, position 32.'

```

So depending on what you will parse, and if you need something more permissive, perhaps another library is more suited. I went with [IronWebScraper](https://ironsoftware.com/csharp/webscraper/), which works better for the HTML I am working with.