Better error messages

This commit is contained in:
Shahram Najm 2018-09-05 12:30:05 +01:00
parent 3f9ac876f7
commit dc153462b1
1 changed files with 14 additions and 0 deletions

View File

@ -83,6 +83,18 @@ int grib_tool_before_getopt(grib_runtime_options* options)
return 0;
}
static void check_code_gen_dump_mode(const char* language)
{
grib_context *c = grib_context_get_default();
const int ok = (strcmp(language, "C")==0 ||
strcmp(language, "fortran")==0 ||
strcmp(language, "python")==0 ||
strcmp(language, "filter")==0);
if (!ok) {
grib_context_log(c, GRIB_LOG_ERROR, "Invalid language specified. Select one of: filter, fortran, python or C");
}
}
int grib_tool_init(grib_runtime_options* options)
{
int opt=grib_options_on("C")+grib_options_on("O");
@ -120,10 +132,12 @@ int grib_tool_init(grib_runtime_options* options)
if (grib_options_on("D:")) {
options->dump_mode = grib_options_get_option("D:");
check_code_gen_dump_mode(options->dump_mode);
json=0;
}
if (grib_options_on("E:")) {
options->dump_mode = grib_options_get_option("E:");
check_code_gen_dump_mode(options->dump_mode);
json=0;
}