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 |
|
WindowMenu |
String |
Contains the name of the window or menu in which |
|
Object |
String |
Contains the name of the object in which the |
|
ObjectEvent |
String |
Contains the event for which the error |
|
Line |
Integer |
Identifies the line in the script at which the |
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 |
|---|---|
|
1 |
Divide by zero. |
|
2 |
Null object reference. |
|
3 |
Array boundary exceeded. |
|
4 |
Enumerated value is out of range for |
|
5 |
Negative value encountered in |
|
6 |
Invalid DataWindow row/column |
|
7 |
Unresolvable external when linking |
|
8 |
Reference of array with null |
|
9 |
DLL function not found in current |
|
10 |
Unsupported argument type in DLL |
|
11 |
Object file is out of date and must be converted |
|
12 |
DataWindow column type does not match GetItem |
|
13 |
Unresolved property reference. |
|
14 |
Error opening DLL library for external |
|
15 |
Error calling external function |
|
16 |
Maximum string size exceeded. |
|
17 |
DataWindow referenced in DataWindow object does |
|
18 |
Function does not return value. |
|
19 |
Cannot convert name in Any variable to |
|
20 |
Database command not successfully |
|
21 |
Bad runtime function reference. |
|
22 |
Unknown object type. |
|
23 |
Cannot assign object of type name to variable of |
|
24 |
Function call does not match its |
|
25 |
Double or Real expression has |
|
26 |
Field name assignment not |
|
27 |
Cannot take a negative to a noninteger |
|
28 |
VBX Error: name. |
|
29 |
Nonarray expected in ANY variable. |
|
30 |
External object does not support data type |
|
31 |
External object data type name not |
|
32 |
Name not found calling external object function |
|
33 |
Invalid parameter type calling external object |
|
34 |
Incorrect number of parameters calling external |
|
35 |
Error calling external object function |
|
36 |
Name not found accessing external object property |
|
37 |
Type mismatch accessing external object property |
|
38 |
Incorrect number of subscripts accessing external |
|
39 |
Error accessing external object property |
|
40 |
Mismatched ANY datatypes in |
|
41 |
Illegal ANY data type in |
|
42 |
Specified argument type differs from required |
|
43 |
Parent object does not exist. |
|
44 |
Function has conflicting argument or return type |
|
45 |
Internal table overflow; maximum number of |
|
46 |
Null object reference cannot be assigned or |
|
47 |
Array expected in ANY variable. |
|
48 |
Size mismatch in array-to-object |
|
49 |
Type mismatch in array-to-object |
|
50 |
Distributed Service Error: name. |
|
51 |
Bad argument list for function/event: |
|
52 |
Distributed Communications Error: |
|
53 |
The server name could not be located. It was |
|
54 |
The server name is rejecting new messages. It is |
|
55 |
The request caused an abnormal termination. The |
|
56 |
A message was not fully |
|
57 |
This connection object is not connected to a |
|
58 |
Object instance does not exist. |
|
59 |
Invalid column range. |
|
60 |
Invalid row range. |
|
61 |
Invalid conversion of number dimensional array to |
|
62 |
The server name is busy and not accepting new |
|
63 |
Function/event with no return value used in |
|
64 |
Object array expected on left side of |
|
65 |
Dynamic function not found. Possible causes |
|
66 |
Invalid subscript for array index |
|
67 |
Null object reference cannot be assigned or |
|
68 |
Null object reference cannot be passed to |
|
69 |
Function name cannot be called from a secured |
|
70 |
External DLL function name cannot be called from |
|
71 |
General protection fault occurred. |
|
72 |
name failed with an operating system error code |
|
73 |
Reference parameters cannot be passed to an |
|
74 |
Reference parameters cannot be passed to a shared |
|
75 |
The server has forced the client to |
|
76 |
Passing null as a parameter to external function |
|
77 |
Object passed to shared/remote object method is |
|
78 |
Listening works only in the Enterprise version of |
|
79 |
The argument to name must be an |
|
80 |
The server has timed out the client |
|
81 |
Function argument file creator must be a |
|
82 |
Function argument file type must be a |
|
83 |
Attempt to invoke a function or event that is not |
|
84 |
Wrong number of arguments passed to |
|
85 |
Error in reference argument passed in |
|
86 |
Ambiguous function/event |
|
87 |
The connection to the server has been |
|
88 |
Cannot ask for ClassDefinition Information on |
|
89 |
5.0 style proxy objects are not supported. Copy |
|
90 |
Cannot assign array of type name to variable of |
|
91 |
Cannot convert name in Any variable to name. |
|
92 |
Required property name is missing. |
|
93 |
CORBA User Exception: |
|
94 |
CORBA System Exception: |
|
95 |
CORBA Objects cannot be created |
|
96 |
Exception Thrown has not been |
|
97 |
Cannot save name because of a circular reference
Suggested actions:
|
|
98 |
Obsolete object reference. |
|
99 |
Error calling method of a PBNI |
|
100 |
Error loading library containing a PBNI |
|
101 |
Error unloading library containing a PBNI |
|
102 |
Error creating a PBNI object. |
|
103 |
Error destroying a PBNI object. |
|
104 |
Error calling PowerBuilder system function |
|
105 |
Executing a HALT statement in a server component |
|
106 |
Function is reserved or not yet |
|
107 |
Argument is out of range. |
|
108 |
Not enough memory to execute the |
|
109 |
Cannot assign a null value to array |
|
201 |
General app error. |
|
220 |
General session error. |
|
221 |
Session creation failed. (HTTP |
|
222 |
Session not created. Please create a session |
|
223 |
Session fails to respond (Invalid |
|
224 |
Session fails to respond (Session does not |
|
225 |
Session fails to respond (Session timed |
|
226 |
Session fails to respond (Session is |
|
230 |
Session fails to respond (License |
|
231 |
The application license is invalid. Please |
|
240 |
Unauthorized. |
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
-
Assign values to the properties of the Error object with the
PopulateError function. -
Call the SignalError function to trigger the SystemError
event.The script for the SystemError event executes.