Topic Path: Symbol Reference > Classes > EIdException Class > EIdException Methods > IfAssigned Method
ContentsIndexHome
PreviousUpNext
EIdException.IfAssigned Method

Raises an instance of the exception based on an object reference.

class procedure IfAssigned(
    const ACheck: TObject; 
    const AMsg: string = ''
);
Parameters 
Description 
ACheck 
Object reference to check for a non-Nil value.
 
AMsg 
Exception message text to assign to the exception instance. 

IfAssigned is a class method used to raise an instance of the exception class when the TObject reference in ACheck has been assigned a non-Nil value. As a class method, IfAssigned can be called without creating a prior instance of the exception class. 

When the object reference in ACheck contains a non-Nil value, IfAssigned calls Toss with the value in AMsg to raise the exception class instance. 

Use IfNotAssigned to raise an instance of the exception class when the object reference contains a Nil value.

Using class methods in an Indy Exception descendant.

  EIdException.IfNotAssigned(AnObject,
    'Object has not been created.');

  EIdException.IfAssigned(AnObject.Data,
    'Object already has data.');

  EIdException.IfTrue(AnObject.ClosedGracefully,
    'Object connection has closed before completion.');

  EIdException.IfFalse(AnObject.Active,
    'Object connection is not open.');

  EIdException.IfNotInRange(AnObject.Port, 30000, 39999,
    'Object port number is invalid for this protocol.');

  // no exception raised... continue processing.
Copyright © 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Post feedback to the Indy Docs Newsgroup.