From 8dfed19991bde0984bdf7761eff3b7bd90150350 Mon Sep 17 00:00:00 2001 From: kremsy Date: Tue, 14 Jan 2014 13:57:10 +0100 Subject: [PATCH] mx error check --- .../ManiaExchangeInfoSearcher.php | 37 +++++++++++++------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/application/core/ManiaExchange/ManiaExchangeInfoSearcher.php b/application/core/ManiaExchange/ManiaExchangeInfoSearcher.php index d59d1960..5f4a29fa 100644 --- a/application/core/ManiaExchange/ManiaExchangeInfoSearcher.php +++ b/application/core/ManiaExchange/ManiaExchangeInfoSearcher.php @@ -161,12 +161,19 @@ class ManiaExchangeInfoSearcher { //TODO rename to ManiaExchangeManager // $mapInfo = FileUtil::loadFile($url, "application/json"); //TODO use mc fileutil $mapInfo = $this->get_file($url); - // TODO errors - /* - * if ($file === false) { $this->error = 'Connection or response error on ' . $url; return array(); } elseif ($file === -1) { $this->error = - * 'Timed out while reading data from ' . $url; return array(); } elseif ($file == '') { if (empty($maps)) { $this->error = 'No data returned - * from ' . $url; return array(); } else { break; } } - */ + + if($mapInfo === false) { + $this->error = 'Connection or response error on ' . $url; + return array(); + } elseif($mapInfo === -1) { + $this->error = 'Timed out while reading data from ' . $url; + return array(); + } elseif($mapInfo == '') { + if(empty($maps)) { + $this->error = 'No data returned from ' . $url; + return array(); + } + } $mxMapList = json_decode($mapInfo); if($mxMapList === null) { @@ -224,12 +231,18 @@ class ManiaExchangeInfoSearcher { //TODO rename to ManiaExchangeManager // $mapInfo = FileUtil::loadFile($url, "application/json"); //TODO use mc fileutil $mapInfo = $this->get_file($url); - // TODO errors - /* - * if ($file === false) { $this->error = 'Connection or response error on ' . $url; return array(); } elseif ($file === -1) { $this->error = - * 'Timed out while reading data from ' . $url; return array(); } elseif ($file == '') { if (empty($maps)) { $this->error = 'No data returned - * from ' . $url; return array(); } else { break; } } - */ + if($mapInfo === false) { + $this->error = 'Connection or response error on ' . $url; + return array(); + } elseif($mapInfo === -1) { + $this->error = 'Timed out while reading data from ' . $url; + return array(); + } elseif($mapInfo == '') { + if(empty($maps)) { + $this->error = 'No data returned from ' . $url; + return array(); + } + } $mxMapList = json_decode($mapInfo); if($mxMapList === null) {