Database Guide

Handling error objects

VisualAge provides a default error routine that puts up a debugger window whenever an error is encountered. You can override this default temporarily or permanently by providing your own response to the error.

The following examples illustrate how to do the following:

Note:To ensure that database processing completes, return an error object or some other appropriate object. Do not return directly from the error block.

Temporarily overriding the default error routine

This sample code temporarily causes an error to print in the Transcript window instead of in a message box.

Before you can use this sample code, you need to define a connection specification and establish a database connection.

To use this sample code, follow these steps:

  1. Evaluate the code using the Inspect command.
  2. Look at the contents of the System Transcript to see the error message generated.
"Temporarily overrides default error routine"
| connection err |
connection := AbtDbmSystem activeDatabaseConnection.
connection openTableNamed: 'NOTABLE'
     ifError: [:error | Transcript cr;
                            show: (error errorText printString).
                 err := error].
^err.

Permanently overriding the default error routine

If you want to override the error routine permanently for all database messages displayed by VisualAge, send the errorBlock: method to the current active connection.

This example assumes that you have an active connection.

To use this sample code, evaluate it using the Inspect command.

"Permanently overrides error routine"
AbtDbmSystem activeDatabaseMgr errorBlock:
     [:error | Transcript show: (error errorText printString).].

Restoring the default error routine

To reset the error routine to the default, supply a value of NIL.

This example assumes that you have an active connection.

To use this sample code, evaluate it using the Execute command.

"Resets error routine to default"
AbtDbmSystem activeDatabaseMgr errorBlock: nil.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]