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

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

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

IfNotAssigned is a class procedure used to raise an instance of the exception class when the TObject reference in ACheck contains an unassigned value. As a class method, IfNotAssigned can be called without creating a prior instance of the exception class. 

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

Use IfAssigned to raise an instance of the exception class when the object reference contains a non-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.');

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