crash: do not call list-proxies if it does not exist.

Additionally, this adds logging for list-proxies call failures.

BUG=chromium:396033
TEST=unittests, test_that logging_UserCrash

CQ-DEPEND=CL:275076

Change-Id: I0515e75476bdc7a0ace8ebc8318e82c337a87374
Reviewed-on: https://chromium-review.googlesource.com/275077
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Daniel Colish <colish@chromium.org>
Tested-by: Daniel Colish <colish@chromium.org>
diff --git a/crash_reporter/crash_sender b/crash_reporter/crash_sender
index 2ad1e46..641ae2d 100755
--- a/crash_reporter/crash_sender
+++ b/crash_reporter/crash_sender
@@ -419,7 +419,18 @@
   # double-quotes are necessary due to a bug in dash with the "local"
   # builtin command and values that have spaces in them (see
   # "https://bugs.launchpad.net/ubuntu/+source/dash/+bug/139097").
-  local proxy="`${LIST_PROXIES} -quiet "${url}" | head -1`"
+  if [ -f "${LIST_PROXIES}" ]; then
+    local proxy ret
+    proxy=$("${LIST_PROXIES}" --quiet "${url}")
+    ret=$?
+    if [ ${ret} -ne 0 ]; then
+      proxy=''
+      lecho -psyslog.warn \
+        "Listing proxies failed with exit code ${ret}"
+    else
+      proxy=$(echo "${proxy}" | head -1)
+    fi
+  fi
   # if a direct connection should be used, unset the proxy variable.
   [ "${proxy}" = "direct://" ] && proxy=
   local report_id="${TMP_DIR}/report_id"