Skip to content

Error Handling

This section describes the error handling system in CATChem, which is designed to be robust, flexible, and easy to use.

Overview

The error handling system in CATChem is built around the ErrorManagerType, which is a centralized error handling object that provides a consistent interface for reporting and managing errors. The system is designed to be used in a variety of contexts, from simple standalone models to complex, fully coupled Earth system models.

Core Components

The Error Manager

The ErrorManagerType is the heart of the error handling system. It provides the following key features:

  • Standardized Error Codes: The system defines a set of standardized error codes that are used to identify specific error conditions.
  • Error Severity Levels: The system defines a set of error severity levels that are used to classify errors based on their severity.
  • Error Categories: The system defines a set of error categories that are used to classify errors based on their source.
  • Error Context Stack: The system provides an error context stack that is used to track the context in which an error occurred. This is useful for debugging.
  • Error Recovery: The system provides mechanisms for recovering from errors and continuing execution.
  • Performance Monitoring: The system provides tools for monitoring the performance of the error handling system.
  • Thread Safety: The system is designed to be thread-safe, which means that it can be used in parallel processing environments.

Error Information

The ErrorInfoType is a data structure that is used to store information about a specific error. It contains the error code, a descriptive message, the severity level, the category, and optional context information.

Error Context

The ErrorContextType is a data structure that is used to track the context in which an error occurred. It contains the name of the routine where the error occurred, a description of the context, the name of the source file, and the line number.

Usage

To use the error handling system, a routine must first get a reference to the ErrorManagerType object. Then, the routine can use the push_context method to push the current context onto the error context stack. If an error occurs, the routine can use the report_error method to report the error. Finally, the routine must use the pop_context method to pop the context from the stack.

Legacy Functions

The error handling system also provides a set of legacy functions for backward compatibility. These functions are:

  • CC_Error: This function is used to report an error.
  • CC_Warning: This function is used to report a warning.
  • CC_CheckVar: This function is used to check if a variable is allocated.