uaf-arctic-eco-modeling / dvm-dos-tem

A process based Dynamic Vegetation, Dynamic Organic Soil, Terrestrial Ecosystem Model.
MIT License
22 stars 24 forks source link

Improve Logging #717

Open dogukanteber opened 6 months ago

dogukanteber commented 6 months ago

We can log more information about the errors. I sometimes encounter No such file or directory errors and have no idea which file couldn't be found. It would be good to add the provided path so that it's easier to fix the error. This doesn't have to be specific for the mentioned error, though. We should provide more information about any NetCDF-related error.

When I checked the codebase, I saw that we pass a status returned from NetCDF methods and check if it's not NC_NOERR:

void handle_error(int status) {
  if (status != NC_NOERR) {
    fprintf(stderr, "%s\n", nc_strerror(status));
    BOOST_LOG_SEV(glg, err) << nc_strerror(status);

    std::string msg = "Exception from netcdf: ";
    msg = msg + nc_strerror(status);

    throw std::runtime_error(msg);

    //exit(-1);
  }
}

I am not sure how to improve the logging but I am open to implementing the suggested implementation.