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

Improve Logging

dogukanteber opened this issue · 0 comments

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.