Click or drag to resize

Adding an Error

Defining custom errors in an IVI driver allows you to return errors with a proper COM HRESULT and a properly formatted error message that can be displayed by various COM-aware IDEs. Internally, the errors and warnings defined for a particular driver are managed as members of a special enum created in the type library. Typically, the enum that houses all of the driver's error and warning code definitions has a name that ends with ErrorCodesEnum.

To add an IVI-COM error to a driver

  1. From Solution Explorer, double-click the Driver Designer node under the Nimbus node.

  2. The Driver Designer opens as a tabbed document window. Select the IVI-COM tab.

  3. From the tree view expand the type library node for the instrument-specific hierarchy. This node is named "<driverName>Lib".

  4. Right-click on the Errors node and choose Add Error.

  5. A new error is added with a default name and the tree node enters edit mode.

  6. With the error node still in edit mode, type the desired name of the error and hit the Enter key.

    Note Note

    By convention, error names start with "E_<projectName>_". However, when typing an error name in the tree view, a shortened form of the name can be used. The "E_<projectName>_" prefix prefix can be excluded. For example, if the desired error is E_ACME4321_BAD_SWEEP, then type only BAD_SWEEP and the full error name will be expanded when the Enter key is pressed.

    When choosing an error name, the following naming rules apply:

    • The name must be unique within the driver.

    • The name must contain only alphanumeric characters and the underscore (_) character.

    • Spaces are not allowed.

    • The name must be uppercase.

  7. After the error is added, the IVI-COM Error General Editor appears in the right portion of the IVI-COM Designer. See the help topic for that Item Editor for details on defining the error further.

  8. If IVI-C wrapper generation is enabled on the IVI-C Page of the Driver Settings Editor, then an IVI-C error is automatically created at this time and associated with the IVI-COM error.

    To view the linked IVI-C error, right-click the IVI-COM error, and choose Go to IVI-C Error.

    To remove the linked IVI-C error, thereby creating an IVI-COM-only error, right-click the IVI-COM error, and choose Delete IVI-C Error.

See Also

Download a complete CHM version of this documentation here.