From: Adam Dickmeiss Date: Wed, 7 Dec 2011 14:08:53 +0000 (+0100) Subject: zoom: extend addinfo with native diagnostics X-Git-Tag: v1.3.18~5 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=f874b10d8097f623e313d15da3b4f7305daa7511;p=metaproxy-moved-to-github.git zoom: extend addinfo with native diagnostics Diagnostics as received by ZOOM C are put into addinfo - including ZOOM, HTTP, SRU and Bib-1 diagnostics. This indicates both a backend diagnostic and the original form. Seems like a big improvement to what we have had so far. --- diff --git a/src/filter_zoom.cpp b/src/filter_zoom.cpp index 84fb20c..39c02e6 100644 --- a/src/filter_zoom.cpp +++ b/src/filter_zoom.cpp @@ -235,37 +235,30 @@ void yf::Zoom::Backend::get_zoom_error(int *error, char **addinfo, const char *msg = 0; const char *zoom_addinfo = 0; const char *dset = 0; - *error = ZOOM_connection_error_x(m_connection, &msg, &zoom_addinfo, &dset); - if (*error) + int error0 = ZOOM_connection_error_x(m_connection, &msg, + &zoom_addinfo, &dset); + if (error0) { - if (*error >= ZOOM_ERROR_CONNECT) - { - // turn ZOOM diagnostic into a Bib-1 2: with addinfo=zoom err msg - *error = YAZ_BIB1_TEMPORARY_SYSTEM_ERROR; - *addinfo = (char *) odr_malloc( - odr, 20 + strlen(msg) + - (zoom_addinfo ? strlen(zoom_addinfo) : 0)); - strcpy(*addinfo, msg); - if (zoom_addinfo) - { - strcat(*addinfo, ": "); - strcat(*addinfo, zoom_addinfo); - } - } + if (!dset) + dset = "Unknown"; + + if (!strcmp(dset, "info:srw/diagnostic/1")) + *error = yaz_diag_srw_to_bib1(error0); + else if (!strcmp(dset, "Bib-1")) + *error = error0; else + *error = YAZ_BIB1_TEMPORARY_SYSTEM_ERROR; + + *addinfo = (char *) odr_malloc( + odr, 30 + strlen(dset) + strlen(msg) + + (zoom_addinfo ? strlen(zoom_addinfo) : 0)); + **addinfo = '\0'; + if (zoom_addinfo && *zoom_addinfo) { - if (dset && !strcmp(dset, "info:srw/diagnostic/1")) - *error = yaz_diag_srw_to_bib1(*error); - *addinfo = (char *) odr_malloc( - odr, 20 + (zoom_addinfo ? strlen(zoom_addinfo) : 0)); - **addinfo = '\0'; - if (zoom_addinfo && *zoom_addinfo) - { - strcpy(*addinfo, zoom_addinfo); - strcat(*addinfo, " "); - } - strcat(*addinfo, "(backend)"); + strcpy(*addinfo, zoom_addinfo); + strcat(*addinfo, " "); } + sprintf(*addinfo + strlen(*addinfo), "(%s %d %s)", dset, error0, msg); } }