chr
2026-04-05 fe750b791d5b517cc4e9bc8e99a9a75139a0cfba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Xml;
using System.Xml.Linq;
 
namespace OpenTap
{
    /// <summary> Contains detailed information about what went wrong while loading or saving information to an XML file. </summary>
    public class XmlError : XmlMessage
    {
        /// <summary> The exception that occured - if any.</summary>
        public virtual Exception Exception { get; }
        
 
        /// <summary> Creates an instance of XmlError. xmlElement may be null. message may be null if exception is set. </summary>
        public XmlError(XElement xmlElement, string message, Exception exception = null) : base(xmlElement, message)
        {
            Exception = exception;
        }
 
        /// <summary> Prints this error in a readable fashion. </summary>
        public override string ToString()
        {
            string message = Message ?? Exception.Message;
            if (Element is IXmlLineInfo lineInfo && lineInfo.HasLineInfo())
                return $"XML Line {lineInfo.LineNumber}: {message}";
            if (Exception is XmlException x)
                return $"XML Line {x.LineNumber}: {message}";
            return message;
        }
    }
}