Unsubscribe( ) event method
Removes a method or procedure as a handler for an ABL or .NET class event.
Return type: VOID
Access: PUBLIC
Applies to: ABL or .NET class events
[publisher
: ]
The object reference to an ABL or .NET object or the type name of an ABL or .NET class that can publish the instance or static event, respectively. If you do not specify apublisher
, it defaults to either THIS-OBJECT whenevent-name
identifies an instance event defined in the current class instance, or to the class type name of the current class definition whenevent-name
identifies a static event defined in the current class hierarchy.event-name
[subscriber
: ]handler-method
An ABL class-based method that you want to remove as a handler forevent-name
, wherehandler-method
is the unquoted name of the instance or static method. If specified,subscriber
can be either the object reference to an ABL class instance wherehandler-method
is defined, or the type name of an ABL class where the statichandler-method
is defined. If you do not specify asubscriber
, it defaults to THIS-OBJECT whenhandler-method
identifies an instance method defined in the current class hierarchy, or to the class type name of the current class definition whenhandler-method
identifies a static method defined in the current class hierarchy.Note that the access mode (PUBLIC, PROTECTED, or PRIVATE) of thehandler-method
definition does not matter to thepublisher
. For example, you can remove a PRIVATE method of the unsubscribing class instance as a handler for an event defined and published by yet another class instance.The signature ofhandler-method
must be run-time compatible with the signature defined for event-name. This includes an overloaded method as long as ABL can identify the signature for a unique overloading that is compatible with the event signature.Thus, ABL raises a compile-time error ifhandler-method
:[subscriber-handle
, ]handler-procedure
A procedure that you want to remove as a handler forevent-name
, wherehandler-procedure
is a character expression that evaluates to the name of an internal procedure. If specified,subscriber-handle
is a handle to a persistent procedure, or other external procedure on the call stack, where the internal procedure is defined. Otherwise,subscriber-handle
defaults to THIS-PROCEDURE.At compile-time, ABL checks thisUnsubscribe( )
method call only to verify that any specifiedsubscriber-handle
is a HANDLE data type and thathandler-procedure
is specified by a character expression. Otherwise, ABL raises a run-time error if the procedure context specified bysubscriber-handle
is not accessible or it does not definehandler-procedure
as an internal procedure.NO-ERROR
Suppresses ABL errors or error messages that would otherwise occur and diverts them to the ERROR-STATUS system handle. If an error occurs, the action of the statement is not completed and execution continues with the next statement. If the statement fails, any persistent side-effects of the statement are backed out. If the statement includes an expression that contains other executable elements, like methods, the work performed by these elements may or may not be completed, depending on the order in which the AVM resolves the expression elements and the occurrence of the error.To check for errors after a statement that uses the NO-ERROR option:
- Check the ERROR-STATUS:ERROR attribute to see if the AVM raised the ERROR condition.
- Check if the ERROR-STATUS:NUM-MESSAGES attribute is greater than zero to see if the AVM has generated error messages.
- Use ERROR-STATUS:GET-MESSAGE(
message-num
) to retrieve a particular message, wheremessage-num
is 1 for the first message.If the statement does not include the NO-ERROR option, you can use a CATCH end block to handle errors raised by the statement.Following are some other important usage notes on the NO-ERROR option:
- NO-ERROR does not suppress errors that raise the STOP or QUIT condition.
- A CATCH statement, which introduces a CATCH end block, is analogous to a NO-ERROR option in that it also suppresses errors, but it does so for an entire block of code. It is different in that the error messages are contained in a class-based error object (generated by the AVM or explicitly thrown), as opposed to the ERROR-STATUS system handle. Also, if errors raised in the block are not handled by a compatible CATCH block, ON ERROR phrase, or UNDO statement, then the error is not suppressed, but handled with the default error processing for that block type.
- When a statement contains the NO-ERROR option and resides in a block with a CATCH end block, the NO-ERROR option takes precedence over the CATCH block. That is, an error raised on the statement with the NO-ERROR option will not be handled by a compatible CATCH end block. The error is redirected to the ERROR-STATUS system handle as normal.
- If an error object is thrown to a statement that includes the NO-ERROR option, the information and messages in the error object are used to set the ERROR-STATUS system handle. This interoperability feature is important for those integrating code that uses the traditional NO-ERROR technique with the newer, structured error handling that features error objects and CATCH end blocks.
- To access more comprehensive error information for a .NET exception, use a CATCH end block instead of the NO-ERROR option. For more information on handling .NET exceptions, see the sections on .NET error handling in OpenEdge Development: GUI for .NET Programming.
The
Unsubscribe( )
method cancels an event subscription by removing the specified method or internal procedure from the list of handlers for the specifiedevent-name
. If you do not specify apublisher
, you can only invokeUnsubscribe( )
in an ABL class definition and on an ABL or .NET event that the ABL class defines or inherits. When you cancel an event handler subscription, ABL does not raise either a run-time error if the specified event handler is not currently on the subscription list for the specified event.See also: Publish( ) event method, Subscribe( ) event method, UNSUBSCRIBE statement
OpenEdge Release 10.2B
|