Rules and Standards

CAA V5 Error Processing Rules

Rules, hints, and tips to manage error processing
Technical Article

Abstract

This article explains how to create your own error objects and messages, and how to process the errors returned by the methods you call.


Error Management Overview

The V5 frameworks deal with four ways of handling errors:

  1. A "custom" returned value is used to convey the method failure to the caller by returning a NULL pointer or a non null integer
  2. The method returns an HRESULT and uses E_FAIL or other E_codes to convey the failure to the caller. A CATError class instance may be associated with the HRESULT
  3. The method throws exceptions to handle critical failures. A CATError class instance makes up the exception
  4. No error management.

Notes:

  1. Throwing exceptions is sometimes associated with returning an HRESULT, a pointer, an integer, etc.
  2. The word exception used alone always means V5 exception, that is CATError class instances thrown using the CATThrow macro. When C++ exceptions are discussed, they are referred to as C++ native exceptions.
  3. mkmk deactivates by default C++ native exceptions. If you need to use C++ native exceptions in your module, add the following flag in the Imakefile.mk file to reactivate them:
    CXX_EXCEPTION=
    Do not add any value after the equal sign. Pay attention not to nest V5 exceptions and C++ native exceptions.

[Top]

Error Management Rules

The following rules must be applied:

[Top]

Rule 1: Each framework border must use HRESULT to report errors and must be exception proof, even if exceptions are internally used.

The framework border that must use HRESULT is made of:

The remaining part of the framework border that cannot use HRESULT is made of:

This rule is declined as follows:

The error management process that this rule implies is:

[Top]

Rule 2: All the returned CATErrors either using an HRESULT or an exception must be documented

This rule implies that:

[Top]

Rule 3: Do not include code that requires error processing in constructors and destructors

This rule implies to either:

[Top]

Comparison between V5 Exceptions, C++ Native Exceptions, and HRESULT

The following table shows differences between these three ways of managing errors.

V5 Exceptions C++ Native Exceptions HRESULT
Compatibility between Softwares No Weak Yes
Distribution Support No/Not authorized CORBA only/Not authorized Yes
Thread Support Yes Yes Yes
Performance Medium Low High
Easy Programming Yes Yes No
Automatic Object Lifecycle Management No Yes No
64-bit support No (to do) Depends on provider Yes
Traceability Bad No No
Signature Checked by Compiler No Yes No
Optimizer No Yes Yes
Debug Yes No No

[Top]


History

Version: 1 [Nov 2001] Document created
[Top]

Copyright © 2000, Dassault Systèmes. All rights reserved.