From 5115095d8fc1fcd0bd9f05d45689f515003b2efe Mon Sep 17 00:00:00 2001 From: Robert Gornall Date: Wed, 23 Mar 2016 17:01:06 +0000 Subject: [PATCH] Give slightly more information on Transport API failure. --- includes/alerts/transport.api.php | 2 +- includes/alerts/transport.hipchat.php | 6 +++++- includes/alerts/transport.pagerduty.php | 2 +- includes/alerts/transport.pushbullet.php | 2 +- includes/alerts/transport.pushover.php | 2 +- includes/alerts/transport.slack.php | 2 +- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/includes/alerts/transport.api.php b/includes/alerts/transport.api.php index 33089b4641..20afc1f5e4 100644 --- a/includes/alerts/transport.api.php +++ b/includes/alerts/transport.api.php @@ -41,7 +41,7 @@ foreach( $opts as $method=>$apis ) { var_dump("API '$host' returned Error"); //FIXME: propper debuging var_dump("Params: ".$api); //FIXME: propper debuging var_dump("Return: ".$ret); //FIXME: propper debuging - return false; + return 'HTTP Status code '.$code; } } } diff --git a/includes/alerts/transport.hipchat.php b/includes/alerts/transport.hipchat.php index 5a209bbefd..a829004c4b 100644 --- a/includes/alerts/transport.hipchat.php +++ b/includes/alerts/transport.hipchat.php @@ -28,6 +28,10 @@ foreach($opts as $option) { } $curl = curl_init(); + if (empty($obj["msg"])) { + return "Empty Message"; + } + if (empty($option["message_format"])) { $option["message_format"] = 'text'; } @@ -60,7 +64,7 @@ foreach($opts as $option) { var_dump("API '$url' returned Error"); var_dump("Params: " . $message); var_dump("Return: " . $ret); - return false; + return 'HTTP Status code '.$code; } } return true; diff --git a/includes/alerts/transport.pagerduty.php b/includes/alerts/transport.pagerduty.php index 4b760df79b..8fb613fa05 100644 --- a/includes/alerts/transport.pagerduty.php +++ b/includes/alerts/transport.pagerduty.php @@ -48,6 +48,6 @@ $ret = curl_exec($curl); $code = curl_getinfo($curl, CURLINFO_HTTP_CODE); if( $code != 200 ) { var_dump("PagerDuty returned Error, retry later"); //FIXME: propper debuging - return false; + return 'HTTP Status code '.$code; } return true; diff --git a/includes/alerts/transport.pushbullet.php b/includes/alerts/transport.pushbullet.php index c5d75f4ef2..f54e7448a2 100644 --- a/includes/alerts/transport.pushbullet.php +++ b/includes/alerts/transport.pushbullet.php @@ -42,6 +42,6 @@ if( $code > 201 ) { if( $debug ) { var_dump($ret); } - return false; + return 'HTTP Status code '.$code; } return true; diff --git a/includes/alerts/transport.pushover.php b/includes/alerts/transport.pushover.php index 5205c14f68..d2f8fba4f4 100644 --- a/includes/alerts/transport.pushover.php +++ b/includes/alerts/transport.pushover.php @@ -86,7 +86,7 @@ foreach( $opts as $api ) { $code = curl_getinfo($curl, CURLINFO_HTTP_CODE); if( $code != 200 ) { var_dump("Pushover returned error"); //FIXME: proper debugging - return false; + return 'HTTP Status code '.$code; } } return true; diff --git a/includes/alerts/transport.slack.php b/includes/alerts/transport.slack.php index e770918e85..cbb9101211 100644 --- a/includes/alerts/transport.slack.php +++ b/includes/alerts/transport.slack.php @@ -45,7 +45,7 @@ foreach( $opts as $tmp_api ) { var_dump("API '$host' returned Error"); //FIXME: propper debuging var_dump("Params: ".$alert_message); //FIXME: propper debuging var_dump("Return: ".$ret); //FIXME: propper debuging - return false; + return 'HTTP Status code '.$code; } } return true;