Handling errors at runtime

A serious error at runtime (such as attempting to access a window that has not been opened) will trigger the SystemError event in the Application object if you have not added exception handling code to take care of the error.

If there is no SystemError script

If you do not write a SystemError script to handle these errors, PowerBuilder displays a message box containing the following information:

  • The number and text of the error message

  • The line number, event, and object in which the error occurred

There is also an OK button that closes the message box and stops the application.

If there is a SystemError script

If there is a script for the SystemError event, PowerBuilder executes the script and does not display the message box. Whether or not you have added TRY/CATCH blocks to your code to trap errors, it is a good idea to build an application-level script for the SystemError event to trap and process any runtime errors that have not been handled, as described in Using the Error object.

For more information about handling exceptions, see the section called “Exception handling in PowerBuilder” in Application Techniques.

Using the Error object

In the script for the SystemError event, you can access the built-in Error object to determine which error occurred and where it occurred. The Error object contains the properties shown in the following table.

Property

Data type

Description

Number

Integer

Identifies the PowerBuilder error.

Text

String

Contains the text of the error message.

WindowMenu

String

Contains the name of the window or menu in which the error occurred.

Object

String

Contains the name of the object in which the error occurred. If the error occurred in a window or menu, the Object property will be the same as the WindowMenu property

ObjectEvent

String

Contains the event for which the error occurred.

Line

Integer

Identifies the line in the script at which the error occurred.


Defining your own Error object

You can customize your own version of the Error object by defining a class user object inherited from the built-in Error object. You can add properties and define object-level functions for your Error object to allow for additional processing. In the Application painter, you can then specify that you want to use your user object inherited from Error as the global Error object in your application. For more information, see Building a standard class user object.

Runtime error numbers

The following table lists the runtime error numbers returned in the Number property of the Error object and the meaning of each number:

Number

Meaning

0001

Divide by zero.

0002

Null object reference.

0003

Array boundary exceeded.

0004

Enumerated value is out of range for function.

0005

Negative value encountered in function.

0006

Invalid DataWindow row/column specified.

0007

Unresolvable external when linking reference.

0008

Reference of array with null subscript.

0009

DLL function not found in current application.

0010

Unsupported argument type in DLL function.

0011

Object file is out of date and must be converted to current version.

0012

DataWindow column type does not match GetItem type.

0013

Unresolved property reference.

0014

Error opening DLL library for external function.

0015

Error calling external function <name>.

0016

Maximum string size exceeded.

0017

DataWindow referenced in DataWindow object does not exist.

0018

Function does not return value.

0019

Cannot convert name in Any variable to name.

0020

Database command not successfully prepared.

0021

Bad runtime function reference.

0022

Unknown object type.

0023

Cannot assign object of type name to variable of type name.

0024

Function call does not match its definition.

0025

Double or Real expression has overflowed.

0026

Field name assignment not supported.

0027

Cannot take a negative to a noninteger power.

0028

VBX Error: name.

0029

Nonarray expected in ANY variable.

0030

External object does not support data type name.

0031

External object data type name not supported.

0032

Name not found calling external object function name.

0033

Invalid parameter type calling external object function name.

0034

Incorrect number of parameters calling external object function name.

0035

Error calling external object function name.

0036

Name not found accessing external object property name.

0037

Type mismatch accessing external object property name.

0038

Incorrect number of subscripts accessing external object property name.

0039

Error accessing external object property name.

0040

Mismatched ANY datatypes in expression.

0041

Illegal ANY data type in expression.

0042

Specified argument type differs from required argument type at runtime in DLL function name.

0043

Parent object does not exist.

0044

Function has conflicting argument or return type in ancestor.

0045

Internal table overflow; maximum number of objects exceeded.

0046

Null object reference cannot be assigned or passed to a variable of this type.

0047

Array expected in ANY variable.

0048

Size mismatch in array-to-object conversion.

0049

Type mismatch in array-to-object conversion.

0050

Distributed Service Error: name.

0051

Bad argument list for function/event: name.

0052

Distributed Communications Error: name.

0053

The server name could not be located. It was probably not started.

0054

The server name is rejecting new messages. It is in the process of shutting down.

0055

The request caused an abnormal termination. The connection has been closed.

0056

A message was not fully transmitted.

0057

This connection object is not connected to a server.

0058

Object instance does not exist.

0059

Invalid column range.

0060

Invalid row range.

0061

Invalid conversion of number dimensional array to object.

0062

The server name is busy and not accepting new connections.

0063

Function/event with no return value used in expression.

0064

Object array expected on left side of assignment.

0065

Dynamic function not found. Possible causes include: pass by value/reference mismatch.

0066

Invalid subscript for array index operation.

0067

Null object reference cannot be assigned or passed to an autoinstantiate.

0068

Null object reference cannot be passed to external DLL function name.

0069

Function name cannot be called from a secured runtime session.

0070

External DLL function name cannot be called from a secured runtime session.

0071

General protection fault occurred.

0072

name failed with an operating system error code of number.

0073

Reference parameters cannot be passed to an asynchronous shared/remote object method.

0074

Reference parameters cannot be passed to a shared object method.

0075

The server has forced the client to disconnect.

0076

Passing null as a parameter to external function name.

0077

Object passed to shared/remote object method is not a nonvisual user object.

0078

Listening works only in the Enterprise version of PowerBuilder.

0079

The argument to name must be an array.

0080

The server has timed out the client connection.

0081

Function argument file creator must be a four-character string.

0082

Function argument file type must be a four-character string.

0083

Attempt to invoke a function or event that is not accessible.

0084

Wrong number of arguments passed to function/event call.

0085

Error in reference argument passed in function/event call.

0086

Ambiguous function/event reference.

0087

The connection to the server has been lost.

0088

Cannot ask for ClassDefinition Information on open painter: name.

0089

5.0 style proxy objects are not supported. Copy the new style proxy that was generated at migration time.

0090

Cannot assign array of type name to variable of type array of name.

0091

Cannot convert name in Any variable to name. Possible cause: uninitialized value.

0092

Required property name is missing.

0093

CORBA User Exception: <exceptionname>.

0094

CORBA System Exception: <exceptionname>.

0095

CORBA Objects cannot be created locally.

0096

Exception Thrown has not been handled.

0097

Cannot save name because of a circular reference problem. Possible causes:

  • This object references another class, which in turn references this object.

  • Some other circular reference is pointing back to this object, causing a deadlock condition.

Suggested actions:

  1. Temporarily remove the circular reference from the referenced object.

  2. Make your required changes to this object to refer to that object.

  3. Add back the circular reference you removed in step 1.

  4. Perform a full rebuild (recommended).

0098

Obsolete object reference.

0099

Error calling method of a PBNI object.

0100

Error loading library containing a PBNI object.

0101

Error unloading library containing a PBNI object.

0102

Error creating a PBNI object.

0103

Error destroying a PBNI object.

0104

Error calling PowerBuilder system function <functionname>.

0105

Executing a HALT statement in a server component is strictly forbidden.

0106

Function is reserved or not yet implemented.

0107

Argument is out of range.

0108

Not enough memory to execute the operation.

0109

Cannot assign a null value to array variables.

0113

Invalid DataWindow column '<colname>' specified at line <linenum> in <eventname> event of object <objectname> of <windowname>.

0114

Invalid DataWindow row '<rownum>' specified at line <linenum> in <eventname> event of object <objectname> of <windowname>.

0201

General app error.

0220

General session error.

0221

Session creation failed. (HTTP error).

0222

Session not created. Please create a session using BeginSession.

0223

Session fails to respond (Invalid session).

0224

Session fails to respond (Session does not exist).

0225

Session fails to respond (Session timed out).

0226

Session fails to respond (Session is killed).

0227

The version of PowerServer Nuget packages does not match that of PowerBuilder. Please either directly update the PowerServer Nuget packages in the Web API solution, or clear the solution folder and then redeploy the PowerServer project.

0230

Session fails to respond (License exception).

0231

The application license is invalid. Please contact the application distributor for more information.

0232

Application Terminated. The version of PowerServer Web APIs does not match that of PowerBuilder in which the application is deployed. Please re-deploy both the application and Web APIs using the same version.

0240

Unauthorized.

0241

Data tamper protection is enabled, but the request data validation has failed. Your request may have been altered or is at risk of tampering.


Some errors terminate the application immediately. They do not trigger the SystemError event.

SystemError event scripts

A typical script for the SystemError event includes a CHOOSE CASE control structure to handle specific errors. To stop the application, include a HALT statement in the SystemError script.

Caution

You can continue your application after a SystemError event, but doing so can cause unpredictable and undesirable effects. Where the application will resume depends on what caused the error. Typically, you are better off reporting the problem to the user, then stopping the application with HALT.

To test the SystemError event script

  1. Assign values to the properties of the Error object with the PopulateError function.

  2. Call the SignalError function to trigger the SystemError event.

    The script for the SystemError event executes.