2 using System.ComponentModel;
3 using System.Diagnostics;
7 namespace Tizen.NUI.Xaml
9 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
10 [EditorBrowsable(EditorBrowsableState.Never)]
11 public class XamlParseException : Exception
13 readonly string _unformattedMessage;
15 static private StringBuilder GetStackInfo()
17 StringBuilder ret = new StringBuilder("\nStack:\n");
19 StackTrace st = new StackTrace();
21 for (int i = 2; i < st.FrameCount; i++)
23 StackFrame sf = st.GetFrame(i);
24 ret.AppendFormat("File:{0}, Method:{1}, Line:{2}\n", sf.GetFileName(), sf.GetMethod().Name, sf.GetFileLineNumber());
30 /// <summary> Initializes a new instance. </summary>
31 [EditorBrowsable(EditorBrowsableState.Never)]
32 public XamlParseException()
36 /// <summary> Initializes a new instance with message. </summary>
37 [EditorBrowsable(EditorBrowsableState.Never)]
38 public XamlParseException(string message) : base(message)
40 _unformattedMessage = message;
43 /// <summary> Initializes a new instance with message and inner exception. </summary>
44 [EditorBrowsable(EditorBrowsableState.Never)]
45 public XamlParseException(string message, Exception innerException = null) : base(message, innerException)
47 _unformattedMessage = message;
50 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
51 [EditorBrowsable(EditorBrowsableState.Never)]
52 public XamlParseException(string message, IXmlLineInfo xmlInfo, Exception innerException = null) : base(FormatMessage(message + GetStackInfo(), xmlInfo), innerException)
54 _unformattedMessage = message;
58 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
59 [EditorBrowsable(EditorBrowsableState.Never)]
60 public IXmlLineInfo XmlInfo { get; private set; }
62 internal string UnformattedMessage
64 get { return _unformattedMessage ?? Message; }
67 static string FormatMessage(string message, IXmlLineInfo xmlinfo)
69 if (xmlinfo == null || !xmlinfo.HasLineInfo())
71 return string.Format("Position {0}:{1}. {2}", xmlinfo.LineNumber, xmlinfo.LinePosition, message);