SupportJPG
  Support Home   |   Search   |   Documentation
ArticleId = kb000107

HOW TO: Using Error Handling in AVR

The information in this article applies to:

    • ASNA Visual RPG; Release 3.1 and higher
    • ActiveX
    • Windows

SUMMARY:

This article will demonstrate on how to use Error Handling in AVR.

STATUS:

Current.

MORE INFORMATION:

In Visual Basic, programmers use the On Error statement. In AVR, error detection is accomplished with the EVAL op-code and the detection and reporting of the error condition are available from the *APP and *ERR built-in objects.

Typically you'll use the *APP object to report Acceler8DB and AS/400 database errors encountered in a database operation by trapping the condition with the ERR indicator. Five properties of this object provide the error number, text, detail and, in AS/400-specific errors, the CPF error.

When working with ActiveX objects, you usually want to trap errors that the object would otherwise raise as a runtime error. Frequently, incorrect parameters in a method are not gracefully handled by the component and it raises an exception rather than returning an error result, for example.

  • To trap an error, you can use the EVAL statement in RPG/400, RPG IV and Free Format:

For example:

  • RPG:
C       EVAL       object.method(x, y, z)    88       indicator 88 is in ERR column
  • AVR's Free Format:
Eval      F2(object.method(x, y, z))        Err(*IN88)
  • You can also review the example including in AVR:

TIP: To report or analyze the error, use the *ERR built-in object to retrieve the Error Number, Error Type, Description and Source.

For example, after your EVAL, you can then do this:

msgbox              msg(*err.Description + " " + *err.Source)
 

Other ASNA Articles:

  • Click here for AVR Release Notes.

Keywords: OnError, example, IDE, develop, capture, trap, "error handling", *APP, *ERR, %ERROR

Last Modified Date: 6/20/2005 11:21:48 AM

Copyright © 2005, 2006 ASNA Inc.

  Support Home   |   Search   |   Documentation