__throwLineNumber
except.h:インデックス への移動
ヘッダーファイル
except.h
構文
extern unsigned _RTLENTRY __ThrowLineNumber();
#define __throwLineNumber __ThrowLineNumber()
説明
このグローバル変数を使用して,送出された例外の名前を取得します。この変数の出力は,表示文字文字列です。
__throwLineNumber を使用して,生成された例外の行番号を取得するには,-xp コンパイラオプションを使ってモジュールをコンパイルする必要があります。
コード例
#include <vcl.h>
#pragma hdrstop
#include <except.h>
USERES("Project1.res");
//---------------------------------------------------------------------------
#pragma option -xp
void MyFunc(void)
{
throw Exception( "The rain in spain lies mainly in the plain." );
}
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
try { MyFunc(); }
catch ( Exception &e )
{ ShowMessage( e.Message + "\n\n"
+ "An exception of type " + __ThrowExceptionName()
+ "\nwas thrown by line " + AnsiString(__ThrowLineNumber())
+ "\nof file " + __ThrowFileName() );
};
return 0;
}