Thursday, October 27, 2011

Debugging with Error Codes

The FDK and the ESTK use the global variable FA_errno to indicate whether or not a plug-in or script has executed correctly in the sense that all function calls were well-formed and  executed correctly in a formal sense. 

Initially FA_errno has the value 0 (Constants.FE_Success). FE_Success has the value 0. All other possible values of FA_errno are negative integers.

The value of  FA_errno remains FE_Success so long as no error occurs. 

You can view the current value of FA_errno in the ESTK Data Browser. Just be sure to connect to FrameMaker first.




If an error takes place, FA_errno is reset to a non-zero value. That value remains until another error causes it to be reset or until you reset it yourself.

The ESTK lists 111 error code constants on pages 59-65 of the FrameMaker 10 Scripting Guide.  Individual functions that set error codes have detailed information within the function documentation.
    What sort of things cause an error code to be set? For example, you might
    • Attempt to set a value for  a read-only property. (Constants.FE_ReadOnly)
    • Attempt to get the value of a property that the object in question does not possess. (Constants.FE_BadPropType)
    • Pass an invalid object identifier to a function. (Constants.FE_BadObjId)
    • Pass the wrong object type of a function (Constants.FE_NotFrame, is one possibility)
    • Request an operation that cannot be carried out.(Constants.FE_BadOperation)

    No comments:

    Post a Comment