RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
System.TRuntimeError Enumeration

TRuntimeError is an enumeration of internal runtime error codes.

Pascal
TRuntimeError = (
  reNone,
  reOutOfMemory,
  reInvalidPtr,
  reDivByZero,
  reRangeError,
  reIntOverflow,
  reInvalidOp,
  reZeroDivide,
  reOverflow,
  reUnderflow,
  reInvalidCast,
  reAccessViolation,
  rePrivInstruction,
  reControlBreak,
  reStackOverflow,
  reVarTypeCast,
  reVarInvalidOp,
  reVarDispatch,
  reVarArrayCreate,
  reVarNotArray,
  reVarArrayBounds,
  reAssertionFailed,
  reExternalException,
  reIntfCastError,
  reSafeCallError,
  reMonitorNotLocked,
  reNoMonitorSupport
);
C++
enum TRuntimeError {
  reNone,
  reOutOfMemory,
  reInvalidPtr,
  reDivByZero,
  reRangeError,
  reIntOverflow,
  reInvalidOp,
  reZeroDivide,
  reOverflow,
  reUnderflow,
  reInvalidCast,
  reAccessViolation,
  rePrivInstruction,
  reControlBreak,
  reStackOverflow,
  reVarTypeCast,
  reVarInvalidOp,
  reVarDispatch,
  reVarArrayCreate,
  reVarNotArray,
  reVarArrayBounds,
  reAssertionFailed,
  reExternalException,
  reIntfCastError,
  reSafeCallError,
  reMonitorNotLocked,
  reNoMonitorSupport
};

The TRuntimeError type is used internally within Delphi when Error is used to generate a run-time exception. It defines the type of run time error that has occured. The values are :

Constant 
Meaning 
reNone  
Undefined error.  
reOutOfMemory  
Out of memory  
reInvalidPtr  
An attempt was made to use a nil or invalid pointer.  
reDivByZero  
An attempt was made to divide by zero.  
reRangeError  
A value out of range was encountered.  
reIntOverflow  
An integer variable exceeded its capacity.  
reInvalidOp  
An invalid operation was attempted.  
reZeroDivide  
An attempt was made to divide by zero.  
reOverflow  
A floating point number exceeded its positive capacity.  
reUnderflow  
A floating point number exceeded its negative capacity  
reInvalidCast  
An invalid type cast operation was attempted.  
reAccessViolation  
An attempt was made to access an invalid storage address.  
rePrivInstruction  
An attempt was made to execute a priveleged instruction.  
reControlBreak  
The user pressed Ctrl-Break to interrupt an operation.  
reStackOverflow  
The internal stack exceeded its capacity.  
reVarTypeCast  
An invalid variable type cast operation was attempted.  
reVarInvalidOp  
An attempt was made to process an invalid variable type.  
reVarDispatch  
 
reVarArrayCreate  
 
reVarNotArray  
 
reVarArrayBounds  
 
reAssertionFailed  
 
reExternalException  
An external exception was encountered.  
reIntfCastError  
 
reSafeCallError  
 

 

Delphi Examples: 

{
This example demostrates the use of ErrorProc and how to catch runtime
errors.
}
procedure MyErrorProc(ErrorCode : Byte; ErrorPtr : Pointer);
var
  ErrorName : String;
begin
  { Get the "name" of the enum value using RTTI }
  ErrorName := GetEnumName(TypeInfo(TRuntimeError), ErrorCode);

  { Show an error box }
  MessageDlg(Format('Error with code %d (%s) risen at $%X.',
      [ErrorCode, ErrorName, Integer(ErrorPtr)]), mtError, [mbOK], 0);
end;

procedure TForm2.btIOErrorClick(Sender: TObject);
begin
  {
  Try to write something onto the console - will raise an
  exception.
  }
  WriteLn('This will generate an error because there is no' +
          ' console attached!');
end;

{$OVERFLOWCHECKS ON}
{$OPTIMIZATION OFF}
{$HINTS OFF}
procedure TForm2.btOverflowErrClick(Sender: TObject);
var
  b : Cardinal;
begin
  {
  Simulate an overflow: Note, enabled the overflow
  checking and disabled optimizations because Delphi's
  compiler will not compile this code otherwise.
  }
  b := $FFFFFFFF;
  b := b * b;
end;
{$HINTS ON}
{$OPTIMIZATION ON}
{$OVERFLOWCHECKS OFF}

procedure TForm2.btRuntimeErrorClick(Sender: TObject);
begin
  { Simulate an access violation }
  System.Error(reAccessViolation);
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
  { Register my System error proc }
  ErrorProc := MyErrorProc;
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!