/* _______ __ __ __ ______ __ __ _______ __ __
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
*
* Copyright (c) 2004, 2005, 2006, 2007 Olof Naessén and Per Larsson
*
* Js_./
* Per Larsson a.k.a finalman _RqZ{a<^_aa
* Olof Naessén a.k.a jansem/yakslem _asww7!uY`> )\a//
* _Qhm`] _f "'c 1!5m
* Visit: http://guichan.darkbits.org )Qk
ws?a-?' ._/L #'
* binary forms, with or without )4d[#7r, . ' )d`)[
* modification, are permitted provided _Q-5'5W..j/?' -?!\)cam'
* that the following conditions are met: j<. a J@\
* this list of conditions and the j(]1u
#include "guisan/platform.hpp"
#ifdef _MSC_VER
#if _MSC_VER <= 1200
#define __FUNCTION__ "?"
#endif
#endif
/*
* A macro to be used when throwing exceptions.
* What it basicly does is that it creates a new exception
* and automatically sets the filename and line number where
* the exception occured.
*/
#define GCN_EXCEPTION(mess) gcn::Exception(mess, \
__FUNCTION__, \
__FILE__, \
__LINE__)
namespace gcn
{
/**
* An exception containing a message, a file and a line number.
* Guichan will only throw exceptions of this class. You can use
* this class for your own exceptions. A nifty feature of the
* excpetion class is that it can tell you from which line and
* file it was thrown. To make things easier when throwing
* exceptions there exists a macro for creating exceptions
* which automatically sets the filename and line number.
*
* EXAMPLE: @code
* throw GCN_EXCEPTION("my error message");
* @endcode
*/
class GCN_CORE_DECLSPEC Exception
{
public:
/**
* Constructor.
*/
Exception();
/**
* Constructor.
*
* @param message the error message.
*/
Exception(std::string message);
/**
* Constructor.
*
* NOTE: Don't use this constructor. Use the GCN_EXCEPTION macro instead.
*
* @param message the error message.
* @param function the function name.
* @param filename the name of the file.
* @param line the line number.
*/
Exception(std::string message,
std::string function,
std::string filename,
int line);
/**
* Gets the function name in which the exception was thrown.
*
* @return the function name in which the exception was thrown.
*/
[[nodiscard]] const std::string& getFunction() const;
/**
* Gets the error message of the exception.
*
* @return the error message.
*/
[[nodiscard]] const std::string& getMessage() const;
/**
* Gets the filename in which the exceptions was thrown.
*
* @return the filename in which the exception was thrown.
*/
[[nodiscard]] const std::string& getFilename() const;
/**
* Gets the line number of the line where the exception was thrown.
*
* @return the line number of the line where the exception was thrown.
*/
[[nodiscard]] int getLine() const;
protected:
std::string mFunction;
std::string mMessage;
std::string mFilename;
int mLine;
};
}
#endif // end GCN_EXCEPTION_HPP
/*
* "Final Fantasy XI is the BEST!... It's even better then water!"
* - Astrolite
* I believe it's WoW now days.
*/