Better error messages

This commit is contained in:
Shahram Najm 2023-04-09 12:45:01 +01:00
parent 87327b6bfb
commit a4d0f05a43
5 changed files with 12 additions and 13 deletions

View File

@ -178,10 +178,7 @@ static void compute_size(grib_accessor* a)
}
}
#if 0
printf("compute_size off=%ld slen=%ld a->offset=%ld\n",
(long)off,(long)slen,(long)a->offset);
#endif
// printf("compute_size off=%ld slen=%ld a->offset=%ld\n", (long)off,(long)slen,(long)a->offset);
a->length = off + (slen - a->offset);
@ -237,7 +234,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
return err;
if (*len < tlen) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %ld values", a->name, tlen);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %ld values", a->name, tlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -315,7 +312,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
grib_handle* hand = grib_handle_of_accessor(a);
if (len[0] < (a->length)) {
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s it contains %ld values",
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s, it contains %ld values",
len[0], a->name, a->length);
len[0] = 0;
return GRIB_ARRAY_TOO_SMALL;

View File

@ -296,7 +296,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
ret = compute_scaled_value_and_scale_factor(value_first, scaled_value_max, scale_factor_max, &lscaled_value, &lscale_factor);
if (ret) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s: Failed to compute %s and %s from %g",
grib_context_log(a->context, GRIB_LOG_ERROR, "Key %s (unpack_double): Failed to compute %s and %s from %g",
a->name, self->scale_first, self->value_first, value_first);
return ret;
}

View File

@ -240,14 +240,14 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
dlonlast = ((double)lonlast) / factor;
if (N == 0) {
grib_context_log(c, GRIB_LOG_ERROR, "global_gaussian unpack_long: N cannot be 0!");
grib_context_log(c, GRIB_LOG_ERROR, "Key %s (unpack_long): N cannot be 0!", a->name);
return GRIB_WRONG_GRID;
}
lats = (double*)grib_context_malloc(c, sizeof(double) * N * 2);
if (!lats) {
grib_context_log(c, GRIB_LOG_ERROR,
"global_gaussian unpack_long: Memory allocation error: %ld bytes", sizeof(double) * N * 2);
"Key %s (unpack_long): Memory allocation error: %zu bytes", a->name, sizeof(double) * N * 2);
return GRIB_OUT_OF_MEMORY;
}
if ((ret = grib_get_gaussian_latitudes(N, lats)) != GRIB_SUCCESS)
@ -333,7 +333,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
lats = (double*)grib_context_malloc(c, sizeof(double) * N * 2);
if (!lats) {
grib_context_log(c, GRIB_LOG_ERROR,
"global_gaussian pack_long: Memory allocation error: %zu bytes", sizeof(double) * N * 2);
"Key %s (pack_long): Memory allocation error: %zu bytes", a->name, sizeof(double) * N * 2);
return GRIB_OUT_OF_MEMORY;
}
if ((ret = grib_get_gaussian_latitudes(N, lats)) != GRIB_SUCCESS)

View File

@ -182,7 +182,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
/* We ignore the 'seconds' in our time calculation! */
if (second != 0) {
grib_context_log(a->context, GRIB_LOG_ERROR,
"Truncating time: non-zero seconds(%ld) ignored", second);
"Key %s (unpack_long): Truncating time: non-zero seconds(%ld) ignored", a->name, second);
}
if (*len < 1)
@ -236,7 +236,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
unpack_long(a, &v, &lsize);
if (*len < 5) {
grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_time : unpack_string : Buffer too small for %s", a->name);
grib_context_log(a->context, GRIB_LOG_ERROR, "Key %s (unpack_string): Buffer too small", a->name);
*len = 5;
return GRIB_BUFFER_TOO_SMALL;

View File

@ -91,15 +91,17 @@ ecbuild_add_executable( TARGET codes_bufr_filter
LIBS ecc_tools )
# grib1to2 script needs to be generated before installation
if( ECCODES_INSTALL_EXTRA_TOOLS )
ecbuild_info("ECCODES_INSTALL_EXTRA_TOOLS enabled")
# grib1to2 script needs to be generated before installation
configure_file( grib1to2.in grib1to2 )
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/grib1to2
DESTINATION ${INSTALL_BIN_DIR}
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ
WORLD_EXECUTE WORLD_READ )
else()
ecbuild_info("ECCODES_INSTALL_EXTRA_TOOLS disabled")
endif()
########################################