ECC-748: better error messages

This commit is contained in:
Shahram Najm 2018-09-07 17:12:24 +01:00
parent 47accafef5
commit e0f82b7288
13 changed files with 14 additions and 13 deletions

View File

@ -400,7 +400,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options,const char* file
int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* file)
{
exit_if_input_is_directory(file->name);
exit_if_input_is_directory(grib_tool_name, file->name);
return 0;
}

View File

@ -88,7 +88,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options,const char* file
int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* file)
{
exit_if_input_is_directory(file->name);
exit_if_input_is_directory(grib_tool_name, file->name);
return 0;
}

View File

@ -73,6 +73,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options,const char* file
int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* file)
{
exit_if_input_is_directory(grib_tool_name, file->name);
return 0;
}

View File

@ -71,7 +71,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options,const char* file
int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* file)
{
exit_if_input_is_directory(file->name);
exit_if_input_is_directory(grib_tool_name, file->name);
return 0;
}

View File

@ -82,7 +82,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options,const char* file
int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* file)
{
exit_if_input_is_directory(file->name);
exit_if_input_is_directory(grib_tool_name, file->name);
return 0;
}

View File

@ -92,7 +92,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options,const char* file
int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* file)
{
exit_if_input_is_directory(file->name);
exit_if_input_is_directory(grib_tool_name, file->name);
return 0;
}

View File

@ -125,7 +125,7 @@ int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* fil
if (!options->current_infile->name) return 0;
if (json) return 0;
exit_if_input_is_directory(file->name);
exit_if_input_is_directory(grib_tool_name, file->name);
sprintf(tmp,"FILE: %s ",options->current_infile->name);
if (!grib_options_on("C"))

View File

@ -66,7 +66,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options,const char* file
int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* file)
{
exit_if_input_is_directory(file->name);
exit_if_input_is_directory(grib_tool_name, file->name);
return 0;
}

View File

@ -160,7 +160,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options,const char* file
int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* file)
{
exit_if_input_is_directory(file->name);
exit_if_input_is_directory(grib_tool_name, file->name);
return 0;
}

View File

@ -67,7 +67,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options,const char* file
int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* file)
{
exit_if_input_is_directory(file->name);
exit_if_input_is_directory(grib_tool_name, file->name);
return 0;
}

View File

@ -193,7 +193,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options,const char* file
int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* file)
{
exit_if_input_is_directory(file->name);
exit_if_input_is_directory(grib_tool_name, file->name);
return 0;
}

View File

@ -1112,13 +1112,13 @@ void grib_tools_write_message(grib_runtime_options* options, grib_handle* h)
#endif
}
int exit_if_input_is_directory(const char* filename)
int exit_if_input_is_directory(const char* tool_name, const char* filename)
{
struct stat s;
int stat_val = stat(filename, &s);
if ( stat_val == 0 ) {
if (S_ISDIR(s.st_mode)) {
fprintf(stderr, "ERROR: \"%s\": Is a directory\n", filename);
fprintf(stderr, "%s: ERROR: \"%s\": Is a directory\n", tool_name, filename);
exit(1);
}
}

View File

@ -199,7 +199,7 @@ int grib_process_runtime_options(grib_context* c,int argc,char** argv,grib_runti
void grib_tools_write_message(grib_runtime_options* options, grib_handle* h);
int grib_tool_new_filename_action(grib_runtime_options* options,const char* file);
int grib_no_handle_action(grib_runtime_options* options,int err);
int exit_if_input_is_directory(const char* filename);
int exit_if_input_is_directory(const char* tool_name, const char* filename);
#endif