-
Notifications
You must be signed in to change notification settings - Fork 11
Fix #731, Improved error message when reading a data that is not defined in specification tree #732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -661,7 +661,7 @@ void Dnc_netcdf_file::put_variable(const Dnc_variable& variable, const Dnc_io& w | |
| m_ctx.logger().trace("Variable `{}' written", variable_name); | ||
| } | ||
|
|
||
| void Dnc_netcdf_file::get_variable(const Dnc_variable& variable, const Dnc_io& read, PDI::Ref_w ref_w) | ||
| void Dnc_netcdf_file::get_variable(const Dnc_variable& variable, const Dnc_io& read, PDI::Ref_w ref_w, const std::string& ref_name) | ||
| { | ||
| if (!ref_w) { | ||
| throw PDI::Permission_error{"Decl_netcdf plugin: Cannot read `{}'. Need write access to read it from file", variable.path()}; | ||
|
|
@@ -690,12 +690,12 @@ void Dnc_netcdf_file::get_variable(const Dnc_variable& variable, const Dnc_io& r | |
| } | ||
| nc_id var_id = var_it->second; | ||
|
|
||
| // read variable and check for scalar type match | ||
| if (auto&& scalar_type = std::dynamic_pointer_cast<const PDI::Scalar_datatype>(ref_w.type())) { | ||
| if (auto&& scalar_type = std::dynamic_pointer_cast<const PDI::Scalar_datatype>(ref_w.type()->evaluate(m_ctx))) { | ||
| nc_type var_nc_type; | ||
| size_t var_nc_type_size; | ||
| nc_try(nc_inq_vartype(src_id, var_id, &var_nc_type), "cannot get type of `{}' from file", variable.path()); | ||
| nc_try(nc_inq_type(0, var_nc_type, NULL, &var_nc_type_size), "can not inquire the size of `{}'", var_nc_type); | ||
|
|
||
| if (scalar_type->kind() == PDI::Scalar_kind::SIGNED) { | ||
| switch (var_nc_type) { | ||
| case NC_BYTE: | ||
|
|
@@ -749,8 +749,22 @@ void Dnc_netcdf_file::get_variable(const Dnc_variable& variable, const Dnc_io& r | |
| scalar_type->datasize() | ||
| }; | ||
| } | ||
| } else if ((*scalar_type) == (*PDI::UNDEF_TYPE)) { | ||
| throw PDI::Type_error{ | ||
| "Can not read `{}' : Invalid type in Decl_netcdf plugin: " | ||
| "The exposed data `{}' is not defined in yaml (meta)data section.", | ||
| variable_name, | ||
| ref_name | ||
| }; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you could do a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this list of |
||
| } else { | ||
| throw PDI::Type_error{"Can not read `{}' : buffer has unknown type", variable_name}; | ||
| throw PDI::Type_error{ | ||
| "Can not read `{}' : Invalid type in Decl_netcdf plugin: " | ||
| "The exposed data `{}' is defined with an unsupported unknown" | ||
| " scalar datatype: {}.", | ||
| variable_name, | ||
| ref_name, | ||
| scalar_type->debug_string() | ||
| }; | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.