NEP 4.3.0
NetCDF Expansion Pack
Loading...
Searching...
No Matches
nxcdf_err.h File Reference

Error-handling macros for the nxCDF backend. More...

#include "config.h"
#include "nep_logging.h"
#include <netcdf.h>
#include <hdf5.h>

Go to the source code of this file.

Macros

#define EBAIL(e)
 Log a NetCDF error, set ret, and jump to the fail: cleanup label.
#define EBAIL2(e)
 Log a NetCDF error, dump the HDF5 error stack, set ret, and jump to the fail: cleanup label.

Detailed Description

Error-handling macros for the nxCDF backend.

These macros mirror the NetCDF-C BAIL/BAIL2 pattern used in libsrc4 and libhdf5, adapted to the local cleanup style (ret and fail:) used by the nxCDF source files. See nxCDF Architecture for the convention in context.

Author
Edward Hartnett
Date
2026-08-31

Macro Definition Documentation

◆ EBAIL

#define EBAIL ( e)
Value:
do { \
EBAILLOG(e); \
ret = e; \
goto fail; \
} while (0)

Log a NetCDF error, set ret, and jump to the fail: cleanup label.

Use this for errors that are not HDF5-specific (for example, invalid arguments or missing state). Every function using it must declare int ret = NC_NOERR; and provide a fail: label.

◆ EBAIL2

#define EBAIL2 ( e)
Value:
#define EBAIL(e)
Definition nep_logging.h:80

Log a NetCDF error, dump the HDF5 error stack, set ret, and jump to the fail: cleanup label.

Use this after an HDF5 API call fails — HDF5 records its own detailed error stack, which H5Eprint2 dumps to stderr. Without logging compiled in (NEP_ENABLE_LOGGING=OFF) it degrades to EBAIL().