From eb77f51e22d3e13a8e14a5d5a0b588cf9e8c56c5 Mon Sep 17 00:00:00 2001 From: Odin Date: Mon, 14 May 2018 09:45:45 +0200 Subject: [PATCH] fix: error reporting from https://github.com/keboola/php-csv/pull/27 --- src/CsvFile.php | 3 ++- tests/bootstrap.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CsvFile.php b/src/CsvFile.php index e0cb108..ee9892e 100644 --- a/src/CsvFile.php +++ b/src/CsvFile.php @@ -324,7 +324,8 @@ public function writeRow(array $row) if (($ret === false) || (($ret === 0) && (strlen($str) > 0))) { throw new Exception( "Cannot write to CSV file " . $this->getPathname() . - ' Error: ' . error_get_last()['message'] . ' Return: ' . json_encode($ret) . + ($ret === false && error_get_last() ? 'Error: ' . error_get_last()['message'] : '') . + ' Return: ' . json_encode($ret) . ' To write: ' . strlen($str) . ' Written: ' . $ret, Exception::WRITE_ERROR, null, diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 77dd6fb..8904000 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,5 +1,6 @@