__throwFileName

From RAD Studio
Jump to: navigation, search

Go Up to except.h Index


Header File

except.h

Syntax

extern char * _RTLENTRY __ThrowFileName();

#define __throwFileName __ThrowFileName()

Description

Use this global variable to get the name of a thrown exception. The output for this variable is a printable character string.

To get the file name for a thrown exception with __throwFileName, you must compile the module with the -xp compiler option.

Example

#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;
}
Retrieved from "https://docwiki.embarcadero.com/RADStudio/Sydney/e/index.php?title=ThrowFileName&oldid=247631"