From dvlasenk@redhat.com Wed Aug 19 23:47:24 2015 From: Denys Vlasenko To: crash-catcher@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> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7807533755017070655==" --===============7807533755017070655== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Fixing my recent breakage. Run-tested. --=20 vda diff -x '*.po' -d -urpN abrt.3/src/daemon/abrt-action-rhtsupport.cpp abrt.4/s= rc/daemon/abrt-action-rhtsupport.cpp --- abrt.3/src/daemon/abrt-action-rhtsupport.cpp 2010-10-20 18:35:13.00000000= 0 +0200 +++ abrt.4/src/daemon/abrt-action-rhtsupport.cpp 2010-10-21 14:58:58.15510985= 0 +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); } =20 --===============7807533755017070655==--