Tools: Error messages

This commit is contained in:
Shahram Najm 2023-08-08 17:31:22 +01:00
parent 8889b5229d
commit d8c17620bb
4 changed files with 15 additions and 15 deletions

View File

@ -76,7 +76,7 @@ int grib_tool_init(grib_runtime_options* options)
if (options->latlon) {
lat = strtod(options->latlon, &theEnd);
if (*theEnd != ',') {
fprintf(stderr, "Error %s: wrong latitude value. Please use 'latitude,longitude'\n", tool_name);
fprintf(stderr, "%s: Wrong latitude value. Please use 'latitude,longitude'\n", tool_name);
exit(1);
}
lon = strtod(++theEnd, &end1);
@ -96,7 +96,7 @@ int grib_tool_init(grib_runtime_options* options)
options->latlon_mode = 1;
}
else {
fprintf(stderr, "Error %s: wrong mode given in option -l\n", tool_name);
fprintf(stderr, "%s: Wrong mode given for the '-l' option (Please use 1 or 4)\n", tool_name);
exit(1);
}
}

View File

@ -97,7 +97,7 @@ int grib_tool_init(grib_runtime_options* options)
if (options->latlon) {
lat = strtod(options->latlon, &theEnd);
if (*theEnd != ',') {
fprintf(stderr, "Error %s: wrong latitude value. Please use 'latitude,longitude'\n", tool_name);
fprintf(stderr, "%s: Wrong latitude value. Please use 'latitude,longitude'\n", tool_name);
exit(1);
}
lon = strtod(++theEnd, &end1);
@ -117,7 +117,7 @@ int grib_tool_init(grib_runtime_options* options)
options->latlon_mode = 1;
}
else {
fprintf(stderr, "Error %s: wrong mode given in option -l\n", tool_name);
fprintf(stderr, "%s: Wrong mode given for the '-l' option (Please use 1 or 4)\n", tool_name);
exit(1);
}
}
@ -286,9 +286,9 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
size_t g_len = sizeof(grid_desc);
err1 = grib_get_string(h, "gridDefinitionDescription", grid_desc, &g_len);
if (!err1) {
fprintf(stderr, "Nearest neighbour functionality is not supported for grid: %s\n", grid_desc);
fprintf(stderr, "%s: Nearest neighbour functionality is not supported for grid: %s\n", tool_name, grid_desc);
} else {
fprintf(stderr, "Nearest neighbour functionality is not supported for this grid type\n");
fprintf(stderr, "%s: Nearest neighbour functionality is not supported for this grid type\n", tool_name);
}
}
GRIB_CHECK_NOLINE(err, 0);

View File

@ -65,7 +65,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) {
fprintf(stderr, "ERROR: Please provide some keys to set through the -s option or use the -r/-d options\n");
fprintf(stderr, "%s: Please provide some keys to set through the -s option or use the -r/-d options\n", tool_name);
exit(1);
}
if (options->verbose)
@ -114,7 +114,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
v = (double*)calloc(size, sizeof(double));
if (!v) {
fprintf(stderr, "failed to allocate %d bytes\n", (int)(size * sizeof(double)));
fprintf(stderr, "%s: Failed to allocate %zu bytes\n", tool_name, size * sizeof(double));
exit(1);
}

View File

@ -296,7 +296,7 @@ static int grib_tool_with_orderby(grib_runtime_options* options)
grib_handle_delete(h);
}
if (set->size==0) fprintf(stderr, "No messages found in fieldset\n");
if (set->size==0) fprintf(stderr, "%s: No messages found in fieldset\n", tool_name);
grib_tool_finalise_action(options);
grib_fieldset_delete(set);
@ -417,7 +417,7 @@ static int grib_tool_without_orderby(grib_runtime_options* options)
fclose(infile->file);
if (infile->handle_count == 0) {
fprintf(stderr, "no messages found in %s\n", infile->name);
fprintf(stderr, "%s: No messages found in %s\n", tool_name, infile->name);
if (options->fail)
exit(1);
}
@ -735,7 +735,7 @@ static void grib_tools_set_print_keys(grib_runtime_options* options, grib_handle
if (ns) {
kiter = grib_keys_iterator_new(h, 0, ns);
if (!kiter) {
fprintf(stderr, "ERROR: Unable to create keys iterator\n");
fprintf(stderr, "%s: Unable to create keys iterator\n", tool_name);
exit(1);
}
@ -743,8 +743,8 @@ static void grib_tools_set_print_keys(grib_runtime_options* options, grib_handle
const char* name = grib_keys_iterator_get_name(kiter);
if (options->print_keys_count >= MAX_KEYS) {
fprintf(stderr, "ERROR: keys list too long (more than %d keys)\n",
options->print_keys_count);
fprintf(stderr, "%s: Keys list too long (more than %d keys)\n",
tool_name, options->print_keys_count);
exit(1);
}
if (options->print_keys[options->print_keys_count].name) {
@ -1273,8 +1273,8 @@ void grib_print_key_values(grib_runtime_options* options, grib_handle* h)
the_index = options->index;
if (the_index >= size) {
fprintf(dump_file, "\n");
fprintf(stderr, "ERROR: Invalid index value %d (should be between 0 and %d)\n",
options->index, (int)(size - 1));
fprintf(stderr, "%s: Invalid index value %d (should be between 0 and %d)\n",
tool_name, options->index, (int)(size - 1));
exit(1);
}
v = values[options->index];