Skip to content
Snippets Groups Projects
Exception.cpp 2.73 KiB
Newer Older
Nick Draper's avatar
Nick Draper committed
#include <iostream>
#include <sstream>
Nick Draper's avatar
Nick Draper committed
#include <string>
#include "MantidKernel/Exception.h"
Nick Draper's avatar
Nick Draper committed


namespace Mantid
{
namespace Kernel
{
Nick Draper's avatar
Nick Draper committed
namespace Exception
{
//-------------------------
// FileError
//-------------------------
/** Constructor
	@param Desc Function description
	@param FName Filename 
Nick Draper's avatar
Nick Draper committed
*/
FileError::FileError(const std::string& Desc,const std::string& FName) :
std::runtime_error(Desc),fileName(FName)
Nick Draper's avatar
Nick Draper committed
{
	outMessage = std::string(std::runtime_error::what()) + " in " + fileName;
}
Nick Draper's avatar
Nick Draper committed
 
/// Copy constructor
FileError::FileError(const FileError& A) :
  std::runtime_error(A),fileName(A.fileName)
{}

/** Writes out the range and limits
	@returns a char array of foramtted error information
*/
const char* FileError::what() const throw()
{
Nick Draper's avatar
Nick Draper committed
	return outMessage.c_str();
Nick Draper's avatar
Nick Draper committed
}

Nick Draper's avatar
Nick Draper committed
//-------------------------
// NotImplementedError
//-------------------------
/** Constructor
	@param Desc Function description
Nick Draper's avatar
Nick Draper committed
*/
NotImplementedError::NotImplementedError(const std::string& Desc) :
std::logic_error(Desc)
{}
 
/// Copy constructor
NotImplementedError::NotImplementedError(const NotImplementedError& A) :
  std::logic_error(A)
{}

/** Writes out the range and limits
	@returns a char array of foramtted error information
*/
const char* NotImplementedError::what() const throw()
{
Nick Draper's avatar
Nick Draper committed
  return std::logic_error::what();
Nick Draper's avatar
Nick Draper committed
}

Nick Draper's avatar
Nick Draper committed
//-------------------------
// NotFoundError
//-------------------------
/** Constructor
	@param Desc Function description
	@param ObjectName The name of the search object
Nick Draper's avatar
Nick Draper committed
*/
NotFoundError::NotFoundError(const std::string& Desc,const std::string& ObjectName) :
std::runtime_error(Desc),objectName(ObjectName)
Nick Draper's avatar
Nick Draper committed
{ 
	outMessage = std::string(std::runtime_error::what()) + " search object " + objectName;
}
Nick Draper's avatar
Nick Draper committed
 
/// Copy constructor
NotFoundError::NotFoundError(const NotFoundError& A) :
  std::runtime_error(A),objectName(A.objectName)
{}

/** Writes out the range and limits
	@returns a char array of foramtted error information
*/
const char* NotFoundError::what() const throw()
{
Nick Draper's avatar
Nick Draper committed
	return outMessage.c_str();
Nick Draper's avatar
Nick Draper committed
}

Nick Draper's avatar
Nick Draper committed
//-------------------------
// ExistsError
//-------------------------
/** Constructor
	@param Desc Function description
	@param ObjectName The name of the search object
Nick Draper's avatar
Nick Draper committed
*/
ExistsError::ExistsError(const std::string& Desc,const std::string& ObjectName) :
std::runtime_error(Desc),objectName(ObjectName)
Nick Draper's avatar
Nick Draper committed
{
	outMessage = std::string(std::runtime_error::what()) + " search object " + objectName;
}
Nick Draper's avatar
Nick Draper committed
 
/// Copy constructor
ExistsError::ExistsError(const ExistsError& A) :
  std::runtime_error(A),objectName(A.objectName)
{}

/** Writes out the range and limits
	@returns a char array of foramtted error information
*/
const char* ExistsError::what() const throw()
{
Nick Draper's avatar
Nick Draper committed
	return outMessage.c_str();
Nick Draper's avatar
Nick Draper committed
}

Nick Draper's avatar
Nick Draper committed
} // namespace Exception
Nick Draper's avatar
Nick Draper committed
} // namespace Kernel
} // namespace Mantid