mirror of https://github.com/ecmwf/eccodes.git
Tools: Improved error messages
This commit is contained in:
parent
bfabfb2e21
commit
937d2fa737
|
@ -1815,9 +1815,9 @@ int grib_set_values(grib_handle* h, grib_values* args, size_t count)
|
|||
for (i = 0; i < count; i++) {
|
||||
if (args[i].error != GRIB_SUCCESS) {
|
||||
grib_context_log(h->context, GRIB_LOG_ERROR,
|
||||
"grib_set_values[%d] %s (type=%s) failed: %s",
|
||||
"grib_set_values[%d] %s (type=%s) failed: %s (message %d)",
|
||||
i, args[i].name, grib_get_type_name(args[i].type),
|
||||
grib_get_error_message(args[i].error));
|
||||
grib_get_error_message(args[i].error), h->context->handle_file_count);
|
||||
err = err == GRIB_SUCCESS ? args[i].error : err;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ EOF
|
|||
|
||||
# Command should fail but not crash
|
||||
set +e
|
||||
${tools_dir}/bufr_filter $tempFilt $sample_bufr4 > $tempOut
|
||||
${tools_dir}/bufr_filter $tempFilt $sample_bufr4 2> $tempOut
|
||||
stat=$?
|
||||
set -e
|
||||
echo stat=$stat
|
||||
|
|
|
@ -365,7 +365,7 @@ cat >$tempFilt <<EOF
|
|||
assert(edition == 0);
|
||||
EOF
|
||||
set +e
|
||||
${tools_dir}/grib_filter $tempFilt $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempOut
|
||||
${tools_dir}/grib_filter $tempFilt $ECCODES_SAMPLES_PATH/GRIB2.tmpl 2> $tempOut
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
|
|
|
@ -34,6 +34,7 @@ cat > $tempRef <<EOF
|
|||
ECCODES ERROR : key 'a_deprecated_key' is unavailable in this version.
|
||||
ECCODES ERROR : Please use the following key(s):
|
||||
ECCODES ERROR : - typeOfOriginalFieldValues
|
||||
ERROR: Key/value not found (message 1)
|
||||
EOF
|
||||
|
||||
diff $tempRef $tempErr
|
||||
|
|
|
@ -53,7 +53,7 @@ int grib_tool_init(grib_runtime_options* options)
|
|||
if (!options->action) {
|
||||
const char* filt = options->infile_extra->name;
|
||||
if (strcmp(filt, "-") == 0) filt = "stdin";
|
||||
fprintf(stderr, "Error: %s: unable to create action\n", filt);
|
||||
fprintf(stderr, "ERROR: %s: unable to create action\n", filt);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,8 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
|
|||
|
||||
err = grib_handle_apply_action(h, options->action);
|
||||
if (err != GRIB_SUCCESS && options->fail) {
|
||||
printf("ERROR: %s\n", grib_get_error_message(err));
|
||||
fprintf(stderr, "ERROR: %s (message %d)\n",
|
||||
grib_get_error_message(err), h->context->handle_file_count);
|
||||
exit(err);
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -62,7 +62,7 @@ int grib_tool_before_getopt(grib_runtime_options* options)
|
|||
int grib_tool_init(grib_runtime_options* options)
|
||||
{
|
||||
if (options->set_values_count == 0 && !options->repack && !options->constant) {
|
||||
printf("ERROR: please provide some keys to set through the -s option or use the -r/-d options\n");
|
||||
fprintf(stderr, "ERROR: Please provide some keys to set through the -s option or use the -r/-d options\n");
|
||||
exit(1);
|
||||
}
|
||||
if (options->verbose)
|
||||
|
@ -73,7 +73,7 @@ int grib_tool_init(grib_runtime_options* options)
|
|||
}*/
|
||||
|
||||
if (grib_options_on("n:") && grib_options_on("d:")) {
|
||||
printf("Error: -n and -d options are incompatible. Choose one of the two please.\n");
|
||||
fprintf(stderr, "ERROR: -n and -d options are incompatible. Choose one of the two please.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ int grib_tool_init(grib_runtime_options* options)
|
|||
if (!options->action) {
|
||||
const char* filt = options->infile_extra->name;
|
||||
if (strcmp(filt, "-") == 0) filt = "stdin";
|
||||
fprintf(stderr, "Error: %s: unable to create action\n", filt);
|
||||
fprintf(stderr, "ERROR: %s: unable to create action\n", filt);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,8 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
|
|||
|
||||
err = grib_handle_apply_action(h, options->action);
|
||||
if (err != GRIB_SUCCESS && options->fail) {
|
||||
printf("ERROR: %s\n", grib_get_error_message(err));
|
||||
fprintf(stderr, "ERROR: %s (message %d)\n",
|
||||
grib_get_error_message(err), h->context->handle_file_count);
|
||||
exit(err);
|
||||
}
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue