diff options
Diffstat (limited to 'mcs/class/Microsoft.Build/Microsoft.Build.Exceptions')
4 files changed, 173 insertions, 1 deletions
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Exceptions/BuildAbortedException.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Exceptions/BuildAbortedException.cs new file mode 100644 index 0000000000..70a2969260 --- /dev/null +++ b/mcs/class/Microsoft.Build/Microsoft.Build.Exceptions/BuildAbortedException.cs @@ -0,0 +1,43 @@ +using System; +using System.Runtime.Serialization; + +namespace Microsoft.Build.Exceptions +{ + public class BuildAbortedException : Exception + { + public BuildAbortedException () + : this ("Build aborted") + { + } + + public BuildAbortedException (string message) + : base (message) + { + } + + public BuildAbortedException (string message, Exception innerException) + : base (message, innerException) + { + } + protected BuildAbortedException (SerializationInfo info, StreamingContext context) + : base (info, context) + { + ErrorCode = info.GetString ("errorCode"); + } + + internal BuildAbortedException (string message, string errorCode) + : base (message + " error code: " + errorCode) + { + ErrorCode = errorCode; + } + + public string ErrorCode { get; private set; } + + public override void GetObjectData (SerializationInfo info, StreamingContext context) + { + base.GetObjectData (info, context); + info.AddValue ("errorCode", ErrorCode); + } + } +} + diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Exceptions/InternalLoggerException.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Exceptions/InternalLoggerException.cs new file mode 100644 index 0000000000..3aecdfdbb0 --- /dev/null +++ b/mcs/class/Microsoft.Build/Microsoft.Build.Exceptions/InternalLoggerException.cs @@ -0,0 +1,57 @@ +using System; +using System.Runtime.Serialization; +using Microsoft.Build.Framework; + +namespace Microsoft.Build.Exceptions +{ + public class InternalLoggerException : Exception + { + public InternalLoggerException () + : this ("Build aborted") + { + } + + public InternalLoggerException (string message) + : base (message) + { + } + + public InternalLoggerException (string message, Exception innerException) + : base (message, innerException) + { + } + + internal InternalLoggerException (string message, Exception innerException, BuildEventArgs buildEventArgs, string errorCode, string helpKeyword, bool initializationException) + : base (message, innerException) + { + BuildEventArgs = buildEventArgs; + ErrorCode = errorCode; + HelpKeyword = helpKeyword; + InitializationException = initializationException; + } + + internal InternalLoggerException (SerializationInfo info, StreamingContext context) + : base (info, context) + { + BuildEventArgs = (BuildEventArgs) info.GetValue ("buildEventArgs", typeof (BuildEventArgs)); + ErrorCode = info.GetString ("errorCode"); + HelpKeyword = info.GetString ("helpKeyword"); + InitializationException = info.GetBoolean ("initializationException"); + } + + public BuildEventArgs BuildEventArgs { get; private set; } + public string ErrorCode { get; private set; } + public string HelpKeyword { get; private set; } + public bool InitializationException { get; private set; } + + public override void GetObjectData (SerializationInfo info, StreamingContext context) + { + base.GetObjectData (info, context); + info.AddValue ("buildEventArgs", BuildEventArgs); + info.AddValue ("errorCode", ErrorCode); + info.AddValue ("helpKeyword", HelpKeyword); + info.AddValue ("initializationException", InitializationException); + } + } +} + diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Exceptions/InvalidProjectFileException.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Exceptions/InvalidProjectFileException.cs index ea2a51dc40..ad05ff6403 100644 --- a/mcs/class/Microsoft.Build/Microsoft.Build.Exceptions/InvalidProjectFileException.cs +++ b/mcs/class/Microsoft.Build/Microsoft.Build.Exceptions/InvalidProjectFileException.cs @@ -28,6 +28,8 @@ using System; using System.Runtime.Serialization; +using Microsoft.Build.Construction; +using Microsoft.Build.Internal.Expressions; namespace Microsoft.Build.Exceptions { @@ -57,10 +59,31 @@ namespace Microsoft.Build.Exceptions : base(message, innerException) { } + internal InvalidProjectFileException (ILocation start, string message, + string errorSubcategory = null, string errorCode = null, string helpKeyword = null) + : this (start != null ? start.File : null, 0, start != null ? start.Column : 0, 0, 0, message, errorSubcategory, errorCode, helpKeyword) + { + } + internal InvalidProjectFileException (ElementLocation start, ElementLocation end, string message, + string errorSubcategory = null, string errorCode = null, string helpKeyword = null) + : this (start != null ? start.File : null, start != null ? start.Line : 0, start != null ? start.Column : 0, + end != null ? end.Line : 0, end != null ? end.Column : 0, + message, errorSubcategory, errorCode, helpKeyword) + { + } public InvalidProjectFileException (string projectFile, int lineNumber, int columnNumber, int endLineNumber, int endColumnNumber, string message, string errorSubcategory, string errorCode, string helpKeyword) + : base(message) { + ProjectFile = projectFile; + LineNumber = lineNumber; + ColumnNumber = columnNumber; + EndLineNumber = endLineNumber; + EndColumnNumber = endColumnNumber; + ErrorSubcategory = errorSubcategory; + ErrorCode = errorCode; + HelpKeyword = helpKeyword; } public override void GetObjectData (SerializationInfo info, StreamingContext context) { @@ -87,8 +110,15 @@ namespace Microsoft.Build.Exceptions public string HelpKeyword { get; private set; } public int LineNumber { get; private set; } public override string Message { - get { return ProjectFile == null ? base.Message : base.Message + " " + ProjectFile; } + get { return ProjectFile == null ? base.Message : base.Message + " " + GetLocation (); } } public string ProjectFile { get; private set; } + + string GetLocation () + { + string start = LineNumber == 0 ? string.Empty : ColumnNumber > 0 ? string.Format ("{0},{1}", LineNumber, ColumnNumber) : string.Format ("{0}", LineNumber); + string end = EndLineNumber == 0 ? string.Empty : EndColumnNumber > 0 ? string.Format (" - {0},{1}", EndLineNumber, EndColumnNumber) : string.Format (" - {0}", EndLineNumber); + return LineNumber == 0 ? ProjectFile : String.Format (" at: {0} ({1}{2})", ProjectFile, start, end); + } } } diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Exceptions/InvalidToolsetDefinitionException.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Exceptions/InvalidToolsetDefinitionException.cs new file mode 100644 index 0000000000..b518d182ac --- /dev/null +++ b/mcs/class/Microsoft.Build/Microsoft.Build.Exceptions/InvalidToolsetDefinitionException.cs @@ -0,0 +1,42 @@ +using System; +using System.Runtime.Serialization; + +namespace Microsoft.Build.Exceptions +{ + public class InvalidToolsetDefinitionException : Exception + { + public InvalidToolsetDefinitionException () + : this ("Invalid toolset definition") + { + } + + public InvalidToolsetDefinitionException (string message) + : base (message) + { + } + + public InvalidToolsetDefinitionException (string message, Exception innerException) + : base (message, innerException) + { + } + protected InvalidToolsetDefinitionException (SerializationInfo info, StreamingContext context) + : base (info, context) + { + ErrorCode = info.GetString ("errorCode"); + } + + internal InvalidToolsetDefinitionException (string message, string errorCode) + : base (message + " error code: " + errorCode) + { + ErrorCode = errorCode; + } + + public string ErrorCode { get; private set; } + + public override void GetObjectData (SerializationInfo info, StreamingContext context) + { + base.GetObjectData (info, context); + info.AddValue ("errorCode", ErrorCode); + } + } +} |