__throwExceptionName

Aus RAD Studio
Wechseln zu: Navigation, Suche

Nach oben zu except.h - Index


Header-Datei

except.h

Syntax

extern char * _RTLENTRY __ThrowExceptionName();

#define __throwExceptionName __ThrowExceptionName()

Beschreibung

Sie verwenden diese Variable, um den Namen einer Exception zu ermitteln, die ausgelöst wurde. Die Ausgabe für diese Variable ist ein druckbarer Zeichenstring.


Beispiel

#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;
}