#ifndef _FEXCEPTION_H_
#define _FEXCEPTION_H_

#include <stdarg.h>
#include <exception>

#include "fstring_def.h"

//class FString;
//---------------------------------------------------------------------
#define EXCEPT_MSG_LEN	1023
class FException : public std::exception {
	//const char *type;
	FString msg;
protected:
	void init(const char *type, const FString& msg);
	void init(const char *type, const char *_fmt, ...) {
		va_list arg;
		va_start(arg, _fmt);
		init("FException", _fmt, arg);
		va_end(arg);
    };
	void init(const char *type, const char *fmt, va_list arg);
public:
	FException() {init("FException", "");}
	FException(const char *_fmt, ...) {
		va_list arg;
		va_start(arg, _fmt);
		init("FException", _fmt, arg);
		va_end(arg);
	}
	FException(const FString& msg) {init("FException", msg);}
	~FException() throw();

	const char *Msg() const;
	//const char *Type() const {return type;}
    virtual const char* what() const throw() {return Msg();}
};
//---------------------------------------------------------------------

#endif
