/*********************************************************************
 * This file is part of the cpplibs suite.
 *
 * Copyright (C) 2001 Topi Mäenpää and Jaakko Viertola
 * All rights reserved.
 *
 * This program is free software. You can redistribute and/or modify
 * it under the terms of the free software licence found in the
 * accompanying file "COPYING". The licence terms must always be
 * redistributed with this source file. The above copyright notice
 * must be reproduced in all modified and unmodified copies of this
 * source file.
 *
 * $Revision: 1.7 $
 *********************************************************************/

#ifndef _EXCEPTION_H
#define _EXCEPTION_H

#include "Object.h"

namespace util
{
	/**
	 * Exception is the base class of all exceptions.
	 **/
	class Exception : public Object
	{
	public:
		/**
		 * Create a new exception with the given message. The standard
		 * format for exception messages is:<br>
		 * <pre>
		 * classname::method(method params): message.
		 * i.e.
		 * Exception::getMessage(): There is no message.
		 * </pre>
		 **/
		Exception(std::string msg) : _strMsg(msg) {}

		/**
		 * Get the message stored in this exception. See the message
		 * format description in Exception(string).
		 * @see #Exception(string)
		 **/
		std::string getMessage() const { return _strMsg; }

	private:
		std::string _strMsg;
	};

	/**
	 * An exception for cases where an invalid argument or arguments were
	 * used in a method or constructor call.
	 **/
	class InvalidArgumentException : public Exception
	{
	public:
		InvalidArgumentException(std::string message) : Exception(message) {}
	};

	/**
	 * NotCloneableException is thrown when the Object::clone() method
	 * is called on a class that does not implement it.
	 **/
	class NotCloneableException : public Exception
	{
	public:
		NotCloneableException(std::string msg) : Exception(msg) {}
	};
}

#endif
