**** Merged from MCS ****
[mono-project.git] / mcs / nant / src / BuildException.cs
blob7940496d33052fa984df1139bec792275a7014ca
1 // NAnt - A .NET build tool
2 // Copyright (C) 2001 Gerry Shaw
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // Gerry Shaw (gerry_shaw@yahoo.com)
19 // Ian MacLean (ian_maclean@another.com)
21 namespace SourceForge.NAnt {
23 using System;
25 /// <summary>
26 /// Thrown whenever an error occurs during the build.
27 /// </summary>
28 public class BuildException : ApplicationException {
30 private Location _location = Location.UnknownLocation;
32 /// <summary>
33 /// Constructs a build exception with no descriptive information.
34 /// </summary>
35 public BuildException() : base() {
38 /// <summary>
39 /// Constructs an exception with a descriptive message.
40 /// </summary>
41 public BuildException(String message) : base(message) {
44 /// <summary>
45 /// Constructs an exception with a descriptive message and an
46 /// instance of the Exception that is the cause of the current Exception.
47 /// </summary>
48 public BuildException(String message, Exception e) : base(message, e) {
51 /// <summary>
52 /// Constructs an exception with a descriptive message and location
53 /// in the build file that caused the exception.
54 /// </summary>
55 /// <param name="location">Location in the build file where the exception occured.</param>
56 public BuildException(String message, Location location) : base(message) {
57 _location = location;
60 /// <summary>
61 /// Constructs an exception with the given descriptive message, the
62 /// location in the build file and an instance of the Exception that
63 /// is the cause of the current Exception.
64 /// </summary>
65 /// <param name="message">The error message that explains the reason for the exception.</param>
66 /// <param name="location">Location in the build file where the exception occured.</param>
67 /// <param name="e">An instance of Exception that is the cause of the current Exception.</param>
68 public BuildException(String message, Location location, Exception e) : base(message, e) {
69 _location = location;
72 public override string Message {
73 get {
74 string message = base.Message;
76 // only include location string if not empty
77 string locationString = _location.ToString();
78 if (locationString != String.Empty) {
79 message = locationString + " " + message;
81 return message;