📄 throwable.h
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -