summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core/XamlParseException.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Core/XamlParseException.cs')
-rw-r--r--Xamarin.Forms.Core/XamlParseException.cs30
1 files changed, 30 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core/XamlParseException.cs b/Xamarin.Forms.Core/XamlParseException.cs
new file mode 100644
index 00000000..42e8b618
--- /dev/null
+++ b/Xamarin.Forms.Core/XamlParseException.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Xml;
+
+namespace Xamarin.Forms.Xaml
+{
+ public class XamlParseException : Exception
+ {
+ readonly string _unformattedMessage;
+
+ public XamlParseException(string message, IXmlLineInfo xmlInfo) : base(FormatMessage(message, xmlInfo))
+ {
+ _unformattedMessage = message;
+ XmlInfo = xmlInfo;
+ }
+
+ public IXmlLineInfo XmlInfo { get; private set; }
+
+ internal string UnformattedMessage
+ {
+ get { return _unformattedMessage ?? Message; }
+ }
+
+ static string FormatMessage(string message, IXmlLineInfo xmlinfo)
+ {
+ if (xmlinfo == null || !xmlinfo.HasLineInfo())
+ return message;
+ return string.Format("Position {0}:{1}. {2}", xmlinfo.LineNumber, xmlinfo.LinePosition, message);
+ }
+ }
+} \ No newline at end of file