throwable.h

来自「一个symbian 冒险游戏代码」· C头文件 代码 · 共 58 行

H
58
字号
#ifndef _LANG_THROWABLE_H
#define _LANG_THROWABLE_H


#include "dprintf.h"
#include <lang/Format.h>


void internalError( const char* fname, int line, const char* expr );


namespace lang
{


/**
 * Base class for all exceptions.
 * 
 * @ingroup lang
 */
class Throwable
{
public:
	/** Creates throwable object with no error description. */
	Throwable();

	/** Creates throwable object with error description. */
	Throwable( const Format& msg );

	/** Returns the error message string. */
	const Format& getMessage() const;

private:
	Format	m_msg;
};

/** 
 * Wrapper for throwing exceptions.
 * Can be made 'work' also on platforms which do not support exceptions.
 */
template <class T> void throwError( T e )
{
	dprintf( "%s\n", e.getMessage().format().c_str() );
#ifdef _WINDOWS
	throw e;
#else
	::internalError( __FILE__, __LINE__, "" );
#endif
}


} // lang


#endif // _LANG_THROWABLE_H


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?