RuntimeError object

The RuntimeError object inherits from the Throwable object and is used by the PowerBuilder virtual machine (PBVM) to throw runtime errors. Runtime errors are also called unchecked exceptions. You do not need to declare where they might be thrown and you do not need to catch them as you do checked exceptions.

When a RuntimeError is thrown, its properties are populated automatically with the runtime information associated with the line where the error occurred. If a RuntimeError is not handled, the Application object SystemError event is triggered and the global Error object is populated with the runtime information.

The following derived types provide more robust error-handling capabilities:

  • DivideByZeroError -- thrown when an attempt is made to divide by zero.

  • NullObjectError  -- thrown when an attempt is made to access an object using a null reference.

  • PBXRuntimeError  -- thrown when an unknown error occurs in a PowerBuilder extension.

  • CORBASystemException  -- thrown when a CORBA system exception is thrown from EAServer.

  • DWRuntimeError  -- thrown when a DataWindow error occurs that is not handled by an Error event script.

  • OLERuntimeError  -- thrown when an OLE error occurs that is not handled by an ocx_error, ExternalException, or Error event script

Additional objects that map to standard CORBA exception types inherit from CORBASystemException. The PowerBuilder exception class name is the same as the CORBA exception name without underscore characters. For example, CORBAFreeMem maps to CORBA_FREE_MEM. You can view the list of CORBASystemException types in the PowerBuilder System Tree or in the Browser.

The descendants of RuntimeError allow you to handle specific runtime errors. For example, you can catch only NullObjectError exceptions in a specific block of code. Alternatively, you can catch all runtime errors with a single CATCH statement. Except for PBXRuntimeError, the error information available in the descendant objects is also available in the RuntimeError object.

PBXRuntimeError has an additional property, DLLName, that identifies the name of the PowerBuilder extension DLL in which the error occurred.

Properties

RuntimeError property

Datatype

Description

ClassDefinition

PowerObject

An object of type PowerObject containing information about the class definition of the object or control

Class

String

Name of the class where the exception occurred

Description

String

(OLERuntimeError only) Textual description of the exception

DLLName

String

(PBXRuntimeError only) Name of the PowerBuilder extension DLL where the exception occurred

HelpFile

String

(OLERuntimeError only) Full file name of Help file containing information about the exception

HelpContext

UnsignedLong

(OLERuntimeError only) Help context ID of the topic in the Help file containing information about the exception

Line

Integer

Line number where the exception occurred

Number

Integer

Number of the PowerBuilder error

ObjectName

String

Name of the object where the exception occurred

RoutineName

String

Name of the event or routine where the exception occurred

Source

String

(OLERuntimeError only) Source of the exception

Text

String

Text associated with the type of exception


Events

RuntimeError event

Occurs

Constructor

When the exception is thrown

Destructor

Immediately after the exception is thrown


Functions

RuntimeError function

Datatype returned

Description

ClassName

String

Returns the name assigned to the object

GetContextService

Integer

Creates a reference to a context-specific instance of the specified service

GetMessage

String

Returns the error message from objects of type Throwable

GetParent

PowerObject

Returns a reference to the name of the parent object

PostEvent

Boolean

Adds an event to the end of the message queue for the object

SetMessage

 

Sets an error message for an object of type Throwable

TriggerEvent

Integer

Triggers a specific event in the object and executes the script for the event

TypeOf

Object

Returns the type of the object