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

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

class procedure IfAssigned(
    const ACheck: TObject; 
    const AMsg: string = ''
Object reference to check for a non-Nil value.
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.

    'Object has not been created.');

    'Object already has data.');

    'Object connection has closed before completion.');

    '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.