/*========================================================================
Copyright (C) 2006 by Geir-Tore Lindsve, Torbjørn Meistad
and Yngve Raudberget, hereby refered to as "the authors".
All rights reserved
Permission is hereby granted, without written agreement and without
license or royalty fees, to use, reproduce, prepare derivative
works, distribute, and display this software and its documentation
for NONCOMMERCIAL RESEARCH AND EDUCATIONAL PURPOSES, provided
that (1) the above copyright notice and the following two paragraphs
appear in all copies of the source code and (2) redistributions,
including without limitation binaries, reproduce these notices in
the supporting documentation.
IN NO EVENT SHALL THE AUTHORS, OR DISTRIBUTORS OF THIS SOFTWARE
BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL,
OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE
AND ITS DOCUMENTATION, EVEN IF THE AUTHORS OR ANY OF THE ABOVE
PARTIES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE AUTHORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO
OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
MODIFICATIONS.
========================================================================*/
using System;
using System.Collections.Generic;
using System.Text;
namespace CLab.Exceptions
{
///
/// ClabException is a generic exception class used for separating exceptions which we throw and system exceptions.
/// Looping through the inner exceptions should reflect the entire stack of messages and what lead to the exception.
///
public class ClabException : Exception
{
///
/// Initializes a new instance of the class.
///
/// The exception message which describes the reason for the exception.
/// The inner exception.
public ClabException(String message, Exception inner)
: base(message, inner)
{
}
///
/// Initializes a new instance of the class.
///
/// The exception message which describes the reason for the exception.
public ClabException(String message)
: base(message)
{
}
///
/// Gets a message that describes the current exception.
///
///
/// The error message that explains the reason for the exception.
public override string Message
{
get
{
if (this.InnerException != null)
{
if (this.InnerException.GetType() == typeof(CLab.Exceptions.ClabInternalErrorException))
return String.Format("Internal error: {0}", base.InnerException.Message);
else if (this.InnerException.GetType() == typeof(CLab.Exceptions.ClabInvalidExpressionException))
return String.Format("Invalid expression: {0}", base.InnerException.Message);
else if (this.InnerException.GetType() == typeof(CLab.Exceptions.ClabSymbolException))
return String.Format("Failed type check: {0}", base.InnerException.Message);
else if (this.InnerException.GetType() == typeof(CLab.Exceptions.ClabXMLParserException))
return String.Format("Encountered a problem parsing the XML file: {0}", base.InnerException.Message);
else
return String.Format("System Exception: {0}", base.Message);
}
else
return String.Format("ClabException: {0}", base.Message);
}
}
}
}