From dvlasenk at redhat.com Wed Aug 19 23:47:24 2015 Content-Type: multipart/mixed; boundary="===============6497035430302436129==" MIME-Version: 1.0 From: Denys Vlasenko To: crash-catcher at lists.fedorahosted.org Subject: abrt-action-rhtsupport: fix error handling Date: Thu, 21 Oct 2010 15:03:19 +0200 Message-ID: <1287666199.23034.3.camel@dhcp-25-227.brq.redhat.com> --===============6497035430302436129== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Fixing my recent breakage. Run-tested. -- = vda diff -x '*.po' -d -urpN abrt.3/src/daemon/abrt-action-rhtsupport.cpp abrt.4= /src/daemon/abrt-action-rhtsupport.cpp --- abrt.3/src/daemon/abrt-action-rhtsupport.cpp 2010-10-20 18:35:13.000000= 000 +0200 +++ abrt.4/src/daemon/abrt-action-rhtsupport.cpp 2010-10-21 14:58:58.155109= 850 +0200 @@ -201,8 +201,35 @@ static void report_to_rhtsupport( package, tempfile ); - VERB3 log("post result:'%s'", result); - printf("STATUS:%s", result); + /* Temporary hackish detection of errors. Ideally, + * send_report_to_new_case needs to have better error reporting. + */ + if (strncasecmp(result, "error", 5) =3D=3D 0) + { + /* + * result can contain "...server says: 'multi-line text= '" + * Replace all '\n' with spaces: + * we want this message to be, logically, one log entry. + * IOW: one line, not many lines. + */ + char *src, *dst; + dst =3D src =3D result; + while (1) + { + unsigned char c =3D *src++; + if (c =3D=3D '\n') + c =3D ' '; + *dst++ =3D c; + if (c =3D=3D '\0') + break; + } + /* Use sanitized string as error message */ + CABRTException e(EXCEP_PLUGIN, "%s", result); + free(result); + throw e; + } + /* No error */ + printf("STATUS:%s\n", result); free(result); } = --===============6497035430302436129==--