Skip to content

Commit

Permalink
Better error message
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Dec 13, 2021
1 parent 5f183a5 commit a73f2eb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
"cmake.configureOnOpen": false,
"files.associations": {
"*.make": "makefile",
"vector": "cpp",
"utility": "cpp",
"ostream": "cpp",
"iostream": "cpp",
"map": "cpp",
"iosfwd": "cpp"
"iosfwd": "cpp",
"filesystem": "cpp"
}
}
12 changes: 6 additions & 6 deletions src/decoders/NetcdfData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@ void TypedAccessor<F, T>::operator()(vector<T>& to, vector<size_t>& start, vecto
std::transform(from.begin(), from.begin() + to.size(), to.begin(), Convertor<F, T>(var));
// for (auto x = start.begin(); x != start.end(); ++x) { cout << "start " << *x << endl; }
// for (auto x = edges.begin(); x != edges.end(); ++x) { cout << "edges " << *x << endl; }

}

template <class F, class T>
void TypedAccessor<F, T>::get(vector<F>& from, vector<size_t>& start, vector<size_t>& edges, NetVariable& var) const {
var.get(&from.front(), start, edges);


}

Netcdf::Netcdf(const string& path, const string& method) : file_(-1) {
int status = nc_open(path.c_str(), NC_NOWRITE, &file_);

if (status != NC_NOERR) {
fprintf(stderr, "ERROR while opening NetCDF file - %s\n", nc_strerror(status));
throw NoSuchNetcdfFile(path);
throw NoSuchNetcdfFile(path, nc_strerror(status));
}

int num_var;
Expand Down Expand Up @@ -157,11 +157,11 @@ int NetDimension::index(const string& val) {
}

int NetDimension::value(const string& val) {

if (variable_ != -1) {
// int index = Index::get(variable_->type(), val, variable_->values(), variable_->num_vals());
NetVariable var(name_, variable_, parent_, "index");

return var.find(val);
}

Expand Down
4 changes: 2 additions & 2 deletions src/decoders/NetcdfData.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class NoSuchNetcdfDimension : public MagicsException {

class NoSuchNetcdfFile : public MagicsException {
public:
NoSuchNetcdfFile(const string& file) :
MagicsException("Netcdf MagException: The file " + file + " does not exist or is not a valid netcdf file") {
NoSuchNetcdfFile(const string& file, const string& why) :
MagicsException("Netcdf MagException: Cannot open " + file + ": " + why) {
MagLog::error() << what() << "\n";
}
};
Expand Down

0 comments on commit a73f2eb

Please sign in to comment.