4 namespace Commons.Xml.Nvdl
6 public class NvdlException : Exception
8 public NvdlException (string message)
13 public NvdlException (string message, Exception inner)
14 : base (message ,inner)
18 internal static string FormatMessage (string message,
19 IXmlLineInfo lineInfo)
21 NvdlElementBase source = lineInfo as NvdlElementBase;
22 XmlReader reader = lineInfo as XmlReader;
23 if (source != null && source.HasLineInfo ())
24 return String.Format ("{0}. {1} ({2},{3})",
25 message, source.SourceUri,
26 source.LineNumber, source.LinePosition);
27 else if (lineInfo != null && lineInfo.HasLineInfo ())
28 return String.Format ("{0}. {3}({1},{2})",
31 lineInfo.LinePosition,
32 reader != null ? reader.BaseURI + ' ' : String.Empty);
38 public class NvdlCompileException : NvdlException
40 public NvdlCompileException (string message,
42 : this (message, null, source)
46 public NvdlCompileException (string message, Exception inner,
48 : base (FormatMessage (message, source), inner)
53 public class NvdlValidationException : NvdlException
55 public NvdlValidationException (string message,
57 : this (message, null, source)
61 public NvdlValidationException (string message, Exception inner,
63 : base (FormatMessage (message, source), inner)
68 public class NvdlInstanceValidationException : NvdlException
70 public NvdlInstanceValidationException (string message,
71 NvdlValidatorGenerator generator,
73 : this (message, null, generator, nvdlLocation)
77 public NvdlInstanceValidationException (string message, Exception inner,
78 NvdlValidatorGenerator generator,
80 : base (FormatMessageWithDefinition (message, nvdlLocation), inner)
84 // assuming that wrapped exception message usually
85 // contains the actual instance location info.
86 static string FormatMessageWithDefinition (string message, string nvdlLocation)
88 return String.Format ("{0}. Related NVDL script: {1}", message, nvdlLocation);