mirror of https://github.com/ecmwf/eccodes.git
ECC-1870: Tools: Improve error message when printing array keys via grib_get, grib_ls
This commit is contained in:
parent
56a7dc39a1
commit
b2a8889658
|
@ -87,6 +87,16 @@ set -e
|
|||
grep -q "unreadable message" $tempText
|
||||
rm -f $outfile
|
||||
|
||||
# ----------------------
|
||||
# Printing array keys
|
||||
# ----------------------
|
||||
set +e
|
||||
${tools_dir}/grib_get -p bitmap $data_dir/reduced_latlon_surface.grib2 > $tempText 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "Hint: Tool grib_get cannot print keys of array type" $tempText
|
||||
|
||||
|
||||
# ----------------------
|
||||
# Wrong message type
|
||||
|
|
|
@ -283,6 +283,16 @@ set -e
|
|||
[ $status -ne 0 ]
|
||||
grep -q "unable to open mask file" $tempText
|
||||
|
||||
# ----------------------
|
||||
# Printing array keys
|
||||
# ----------------------
|
||||
set +e
|
||||
${tools_dir}/grib_ls -p bitmap $data_dir/reduced_latlon_surface.grib2 > $tempText 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "Hint: Tool grib_ls cannot print keys of array type" $tempText
|
||||
|
||||
|
||||
# Clean up
|
||||
rm -f $temp1 $temp2 $tempText $tempLog
|
||||
|
|
|
@ -1239,14 +1239,18 @@ void grib_print_key_values(grib_runtime_options* options, grib_handle* h)
|
|||
//GRIB_CHECK_NOLINE(ret, options->print_keys[i].name);
|
||||
grib_context_log(h->context, GRIB_LOG_ERROR, "%s (%s)",
|
||||
options->print_keys[i].name, grib_get_error_message(ret));
|
||||
if (ret == GRIB_ARRAY_TOO_SMALL || ret == GRIB_BUFFER_TOO_SMALL) {
|
||||
fprintf(dump_file, "\tHint: Tool %s cannot print keys of array type. Use grib_filter.\n", tool_name);
|
||||
}
|
||||
exit(ret);
|
||||
}
|
||||
if (ret == GRIB_NOT_FOUND) {
|
||||
strcpy(value, notfound);
|
||||
} else {
|
||||
fprintf(dump_file, "%s (%s)\n", options->print_keys[i].name, grib_get_error_message(ret));
|
||||
if (ret == GRIB_ARRAY_TOO_SMALL)
|
||||
if (ret == GRIB_ARRAY_TOO_SMALL || ret == GRIB_BUFFER_TOO_SMALL) {
|
||||
fprintf(dump_file, "\tHint: Tool %s cannot print keys of array type. Use grib_filter.\n", tool_name);
|
||||
}
|
||||
exit(ret);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue