mirror of https://github.com/ecmwf/eccodes.git
Better error handling
This commit is contained in:
parent
608bce2447
commit
d4c367f274
|
@ -86,7 +86,7 @@ int grib_print(grib_handle* h, const char* name, grib_dumper *d ){
|
|||
void grib_dump_content(grib_handle* h, FILE* f,const char* mode,unsigned long option_flags,void *data)
|
||||
{
|
||||
grib_dumper *dumper;
|
||||
dumper = grib_dumper_factory(mode?mode:"serialize",h,f,option_flags,data);
|
||||
dumper = grib_dumper_factory(mode?mode:"serialize",h,f,option_flags,data);
|
||||
grib_dump_header(dumper,h);
|
||||
grib_dump_accessors_block(dumper,h->root->block);
|
||||
grib_dump_footer(dumper,h);
|
||||
|
@ -100,7 +100,8 @@ grib_dumper* grib_dump_content_with_dumper(grib_handle* h, grib_dumper* dumper,
|
|||
count=dumper->count;
|
||||
count++;
|
||||
}
|
||||
dumper = grib_dumper_factory(mode?mode:"serialize",h,f,option_flags,data);
|
||||
dumper = grib_dumper_factory(mode?mode:"serialize",h,f,option_flags,data);
|
||||
if (!dumper) return NULL;
|
||||
dumper->count=count;
|
||||
|
||||
grib_dump_header(dumper,h);
|
||||
|
|
|
@ -87,7 +87,7 @@ int grib_tool_init(grib_runtime_options* options)
|
|||
options->dump_mode = "json";
|
||||
json_option=grib_options_get_option("j:");
|
||||
if (strlen(json_option)>1 || ( json_option[0] != 's' && json_option[0]!= 'f' && json_option[0]!= 'a')) {
|
||||
printf("wrong json option %s\n",json_option);
|
||||
printf("%s: Invalid JSON option %s\n", grib_tool_name, json_option);
|
||||
exit(1);
|
||||
}
|
||||
json=1;
|
||||
|
@ -211,7 +211,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
|
|||
grib_dump_content(h,stdout,options->dump_mode,options->dump_flags,0);
|
||||
break;
|
||||
default :
|
||||
printf("unknown json option %s\n",json_option);
|
||||
printf("Unknown JSON option %s\n",json_option);
|
||||
exit(1);
|
||||
}
|
||||
if (!strcmp(options->dump_mode,"default"))
|
||||
|
@ -235,6 +235,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
|
|||
return err;
|
||||
}
|
||||
dumper=grib_dump_content_with_dumper(h,dumper,stdout,options->dump_mode,options->dump_flags,0);
|
||||
if (!dumper) exit(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue