/* This file is automatically generated by ./errors.pl, do not edit */

#include "grib_api_internal.h"

static const char *errors[] = {
!ERRORS go in here
};

#define NUMBER(a) sizeof(a)/sizeof(a[0])

const char* grib_get_error_message(int code)
{
  code = -code;
  if(code <0 || code >= NUMBER(errors)) {
    static char mess[80];
    sprintf(mess,"Unknown error %d",code);
    return mess;
    }
  return errors[code];
}

void grib_check(const char* call,const char*  file,int line,int e,const char* msg)
{
	grib_context* c=grib_context_get_default();
    if(e) {
		if (file) {
			fprintf(stderr,"%s at line %d: %s failed: %s",
				file,line, call,grib_get_error_message(e));
			if (msg) fprintf(stderr," (%s)",msg);
			printf("\n");
		} else {
			grib_context_log(c,GRIB_LOG_ERROR,"%s",grib_get_error_message(e));
		}
        exit(e);
    }
}

