Fix PHP Fatal error "Method Icinga\File\Csv::__toString() must not throw an exception in /vagrant/test/php/library/Icinga/File/CsvTest.php on line 35"

This commit is contained in:
Alexander Klimov 2014-06-23 12:40:13 +02:00
parent 1532594948
commit 0065cbe998
1 changed files with 18 additions and 13 deletions

View File

@ -5,6 +5,7 @@
namespace Icinga\File;
use Icinga\Data\Browsable;
use Exception;
class Csv
{
@ -27,6 +28,7 @@ class Csv
public function __toString()
{
try {
$first = true;
$csv = '';
foreach ($this->query->getQuery()->fetchAll() as $row) {
@ -42,5 +44,8 @@ class Csv
}
return $csv;
} catch (Exception $e) {
return (string) $e;
}
}
}